home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MISC / TEMPLED / TPLEDSRC.ARC / Source (.txt) < prev   
RISC OS BBC BASIC V Source  |  1997-09-17  |  176KB  |  7,584 lines

  1.  Source code for !TemplEd
  2.  This application is FreeWare. (c) 1992-1997 Dick Alstein
  3. Appl$="TemplEd"
  4. Version$="1.34 (22-Sep-97)"
  5.  *** main program and top-level procs ***
  6. Quit%=
  7. 2PollMask%=(1<<0)+(1<<4)+(1<<5)+(1<<11)+(1<<12)
  8. error(0)
  9.  Support%=3 
  10.  "WimpExt_PrePoll"
  11. /    
  12.  "Wimp_Poll",PollMask%,Blk% 
  13.  reason%
  14. <    
  15.  "WimpExt_Action",ThisTask%,Blk%,reason% 
  16.  reason%
  17. /    
  18.  "Wimp_Poll",PollMask%,Blk% 
  19.  reason%
  20.  reason% 
  21. ,      
  22.  "Wimp_GetPointerInfo",,PtrInfo%
  23. 1      
  24.  (PtrInfo%!8>0) 
  25.  Mbuttons_Released% 
  26. *        
  27.  signal press of mouse button
  28.          Mbuttons_Released%=
  29. N        
  30. click(PtrInfo%!0,PtrInfo%!4,PtrInfo%!8,PtrInfo%!12,PtrInfo%!16,0)
  31.       
  32.         
  33.  PtrInfo%!8=0 
  34. 9          
  35.  Mbuttons_Released%) 
  36.  (Drag_Type%=7) 
  37. M            
  38.  detected end of workarea-resize - set bottomright corner of
  39. 9            
  40.  work area to currently visible position
  41.  #            WinBlk%!0=Drag_Win%
  42. !1            
  43.  "Wimp_GetWindowState",,WinBlk%
  44. ":            WinBlk%!52=WinBlk%!12-WinBlk%!4+WinBlk%!20
  45. #=            WinBlk%!48=-(WinBlk%!16-WinBlk%!8-WinBlk%!24)
  46. $4            Drag_Win%=
  47. redefinewindow(WinBlk%,
  48.           
  49. &"          Mbuttons_Released%=
  50.           Drag_Type%=-1
  51. ("          TimedDrag_Enabled%=
  52.         
  53. *G          
  54.  button still pressed - test if OK to start "timed drag"
  55. +H          
  56. (PtrInfo%!0-ThisClickX%)+
  57. (PtrInfo%!4-ThisClickY%)>16 
  58. ,@            TimedDrag_Enabled%=
  59.  moved mouse since click
  60.           
  61. .$          
  62.  TimedDrag_Enabled% 
  63. /I            
  64. -ThisClickTime%)>DragInterval%) 
  65.  (PtrInfo%!16>=0) 
  66. 0&              
  67.  "Wimp_DragBox",-1
  68. 1D              
  69. starticondrag(PtrInfo%!8,PtrInfo%!12,PtrInfo%!16)
  70. 2&              TimedDrag_Enabled%=
  71.             
  72.           
  73.         
  74.       
  75.  1 : 
  76. redraw(Blk%!0)
  77.       
  78.  (Blk%!0=TemplW%)
  79. :/        c%=(Blk%!12-Blk%!4) 
  80.  TemplW_IconX%
  81.         
  82.  c%<1 
  83.  c%=1
  84. <         
  85.  TemplW_Cols%<>c% 
  86.           TemplW_Cols%=c%
  87. >!          
  88. redefinebrowser(
  89.           Blk%!0=TemplW%
  90.         
  91.       
  92.       
  93.  Blk%!0=OptionsW% 
  94. C7        
  95. openpane(OptPaneW%,Blk%!28,Blk%!4,Blk%!16)
  96.         Blk%!28=OptPaneW%
  97.       
  98. F$      
  99.  "Wimp_OpenWindow",,Blk%
  100.       
  101.  Blk%!0=OptionsW% 
  102. H7        
  103. openpane(OptPaneW%,Blk%!28,Blk%!4,Blk%!16)
  104.       
  105. K$      no%=
  106. whichtemplate(Blk%!0)
  107.       
  108.  no%>=0 
  109.         
  110. closetemplate(no%)
  111.       
  112.         
  113.  -1) 
  114. P"          
  115. closewindow(Blk%!0)
  116.         
  117. R.        
  118.  "Wimp_GetPointerInfo",,PtrInfo%
  119. SD        
  120.  (Blk%!0=TemplW%)
  121. (PtrInfo%!8=1)
  122. MainFname$,".")>0) 
  123. TG          
  124.  "Wimp_StartTask","Filer_OpenDir "+
  125. dirname(MainFname$)
  126.         
  127.       
  128. W<    
  129.  6 : 
  130. click(Blk%!0,Blk%!4,Blk%!8,Blk%!12,Blk%!16,
  131. X7    
  132.  7 : 
  133. finishdrag(Blk%!0,Blk%!4,Blk%!8,Blk%!12)
  134. Y)    
  135.  8 : 
  136. key(Blk%!0,Blk%!4,Blk%!24)
  137.  9 : 
  138. menuselect(Blk%)
  139. [     
  140.  17,18 : 
  141. receive(Blk%)
  142.  IcInfo_Active% 
  143. icinf_update
  144.  Quit%
  145. font_loseall
  146. support(0)
  147. msg_exit
  148.  "Wimp_CloseDown"
  149.  p%,fn$,i%,mask%,flg%
  150.  "OS_GetEnv" 
  151.  ErrBlk% &100
  152.  "Wimp_Initialise",200,&4B534154,Appl$ 
  153.  OSversion%,ThisTask%
  154. error(1)
  155.  ScrapBlk% &100      : 
  156.  block to hold various temporary data
  157. n'ApplDir$=
  158. readvarval("TemplEd$Dir")
  159. heap_init           : 
  160.  initialize heap
  161. msg_init            : 
  162.  load Messages file
  163.  read max-values for buffers (set in !Run file)
  164. r8MaxTemplates%=
  165. readvarval("TemplEd$MaxTemplates"))
  166. s0MaxIcons%=
  167. readvarval("TemplEd$MaxIcons"))
  168. t8MaxIndirSize%=
  169. readvarval("TemplEd$MaxIndirSize"))
  170.  lower bounds for Max* variables
  171.  MaxTemplates%<4 
  172.  MaxTemplates%=4
  173.  MaxIcons%<64 
  174.  MaxIcons%=64
  175.  MaxIndirSize%<&1000 
  176.  MaxIndirSize%=&1000
  177.  declaration of data blocks and arrays (variable size)
  178. SelBlkSize%=4*MaxIcons%
  179. {KSelBlk%=
  180. heap_get(SelBlkSize%)       : 
  181.  to hold list of selected icons
  182. |#SelBlk2%=
  183. heap_get(SelBlkSize%)
  184. }MTemplNames%=
  185. heap_get(MaxTemplates%*28) : 
  186.  to store template + icon name
  187. ~MTemplHandle%=
  188. heap_get(4*MaxTemplates%) : 
  189.  handles of the user templates
  190. PPaneFlag%=
  191. heap_get(MaxTemplates%)   : 
  192.  array for 'Pane' flags of templates
  193. EMaxTemplateSize%=92+32*MaxIcons%      : 
  194.  max size for a template
  195. MMaxTemplateSize%+=MaxIndirSize%       : 
  196.  extra space for indirected data
  197. 'WinBlk%=
  198. heap_get(MaxTemplateSize%)
  199. (FileIndexSize%=16+MaxTemplates%*24+4
  200. NFileIndex%=
  201. heap_get(FileIndexSize%) : 
  202.  contains index of a template file
  203.  declaration of data blocks and arrays (fixed size)
  204.  IconBlk% 40
  205.  Blk% &100           : 
  206.  for data returned by Wimp_Poll
  207.  PtrInfo% 20         : 
  208.  to store pointer info
  209.  NumValidStr% 8      : 
  210.  validation string for entering a number
  211. $NumValidStr%="A0-9"
  212.  FpNumValidStr% 8    : 
  213.  for entering a floating point number
  214. $FpNumValidStr%="A0-9."
  215. INrTemplates%=0                   : 
  216.  current number of user templates
  217. KTemplatesOpen%=0                 : 
  218.  number of templates currently open
  219. NSysIndirSize%=&1800         : 
  220.  size of indirected data for system windows
  221.  IndirBlk% SysIndirSize%
  222. @IndirEnd%=IndirBlk%         : 
  223.  pointer to first unused byte
  224. HIndirFree%=SysIndirSize%    : 
  225.  remaining free space after IndirEnd%
  226.  IconText%(36)           : 
  227.  pointers to indirected text icons
  228.  IconTextWhdl%(36)       : 
  229.  corresponding window handles
  230.  IconTextIhdl%(36)       : 
  231.  corresponding icon handles
  232.  CselText%(12)           : 
  233.  pointers to text in colour-select boxes
  234.  CselTextWhdl%(12)       : 
  235.  corresponding window handles
  236.  CselTextIhdl%(12)       : 
  237.  corresponding icon handles
  238.  IcButton% 20*16         : 
  239.  names of button types for icons
  240.  WinButton% 20*16        : 
  241.  names of button types for windows
  242.  i%=0 
  243. 3  $(IcButton%+20*i%)=
  244. msg_lookup0("ICBT"+
  245. (i%))
  246. 4  $(WinButton%+20*i%)=
  247. msg_lookup0("WNBT"+
  248. (i%))
  249.  WinEd_Col%(6)      : 
  250.  colours in the colour-select boxes
  251.  InverseColour%(15) : 
  252.  to display text in colour boxes / colour menu
  253.  i%=0 
  254.  0,1,2,3,9,12,14
  255.       InverseColour%(i%)=7
  256.         
  257.       InverseColour%(i%)=0
  258.  DragBlk% 40     : 
  259.  data block for starting drags
  260.  FontUsage%(256) : 
  261.  counts number of icons that use a font
  262.  Fra% 256        : 
  263.  font reference array for loading+saving templates
  264.  FontData% 64    : 
  265.  buffer for reading font data
  266.  Mouse_Ptt% 16        : 
  267.  pixel translation table for pointer changes
  268.  initialise global variables
  269. /IcEd_Win%=-1000          : 
  270.  invalid values
  271. IcEd_Icon%=-1000
  272. WinEd_Win%=-1
  273. 5Mbuttons_Released%=
  274.  to debounce mouse clicks
  275. ?ThisClickTime%=
  276.       : 
  277.  to store data of last mouse click
  278. ThisClickX%=-1000
  279. ThisClickY%=-1000
  280. ThisClickButton%=0
  281. ITimedDrag_Enabled%=
  282.  can I start "timed drag" from current click?
  283. LDragInterval%=50         : 
  284.  interval after which "timed drag" can start
  285. JDclickInterval%=50       : 
  286.  max time between clicks of a double-click
  287. HNextIconNr%=0            : 
  288.  for semi-automatic renumbering of icons
  289. :LastMenu%=-1             : 
  290.  handle of last menu shown
  291. FLastMenu_Win%=-31        : 
  292.  window above which last menu was made
  293. 4LastMenu_Icon%=-1        : 
  294.  icon handle of same
  295. ;MainFname$="Templates"   : 
  296.  save all templates as ....
  297. @SelFname$="Selection"    : 
  298.  save template selection as ....
  299. @ExportTname$="TemplText" : 
  300.  save exported templates as ....
  301. AExportIname$="IconNames" : 
  302.  save exported icon names as ....
  303. HSavingSelection%=
  304.    : 
  305.  was last save dialogue to save a selection?
  306. FExporting%=
  307.          : 
  308.  was last save dialogue to export as text?
  309. BQuitAfterSave%=
  310.      : 
  311.  quit program after current save proc?
  312. GNewFname$=""             : 
  313.  name of new template file to be loaded
  314. BChangesMade%=
  315.        : 
  316.  have current templates been modified?
  317. KUserSprites%=1  : 
  318.  sprites in user templates from Wimp area (at first)
  319. BSpriteFname$="" : 
  320.  name of sprite file if not using Wimp area
  321. CDrag_Type%=-1   : 
  322.  type of current drag operation (-1 => none)
  323. LSupport%=0      : 
  324.  is in setup, but must exist before loading templates
  325.  create icon on icon bar
  326. IconBlk%!0=-1
  327. IconBlk%!4=0 : IconBlk%!8=0
  328. #IconBlk%!12=68 : IconBlk%!16=68
  329. IconBlk%!20=&7000301A
  330. $(IconBlk%+24)="!templed"
  331.  "Wimp_CreateIcon",,IconBlk% 
  332.  BarIcon%
  333.  load system sprites
  334. 4SysSprites%=
  335. loadspritefile(ApplDir$+".Sprites")
  336.  initialise font reference arrays
  337.  i%=0 
  338.   Fra%?i%=0
  339.  load system templates and set pointers to indirected data
  340.  "Wimp_OpenTemplate",,ApplDir$+".Templates"
  341. ?InfoW%=
  342. loadtemplate("Info",WinBlk%,IndirEnd%,IndirFree%,1)
  343. $$(WinBlk%!(92+3*32+20))=Version$
  344. OTemplW%=
  345. loadtemplate("Templates",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  346. DTemplTbar%=WinBlk%!76           : 
  347.  pointer to text in title bar
  348. $(TemplTbar%)=MainFname$
  349. i%=WinBlk%+92
  350. ITemplW_IconX%=i%!8-i%!0 + 8     : 
  351.  size of an icon in browser window
  352.  TemplW_IconY%=i%!12-i%!4 + 8
  353. 2TemplW_IconFlags%=i%!16         : 
  354.  icon flags
  355. DTemplW_Cols%=(WinBlk%!12-WinBlk%!4) 
  356.  TemplW_IconX% : 
  357.  #columns
  358.  TemplW_Cols%<1 
  359.  TemplW_Cols%=1
  360. ScrapBlk%!0=TemplW%
  361. ScrapBlk%!4=0
  362.  "Wimp_DeleteIcon",,ScrapBlk% : 
  363.  icon is only used to set size
  364. MIcEdW%=
  365. loadtemplate("IconEdit",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  366. IcEdTbar%=WinBlk%!76
  367. linkicontext(0,WinBlk%,23)  : 
  368.  text in a text icon
  369. linkicontext(1,WinBlk%,24)  : 
  370.  name of a sprite
  371. linkicontext(2,WinBlk%,25)  : 
  372.  validation string
  373. linkicontext(3,WinBlk%,26)  : 
  374.  max size
  375. linkicontext(4,WinBlk%,28)  : 
  376.  icon button type
  377. linkicontext(5,WinBlk%,31)  : 
  378. linkicontext(19,WinBlk%,45) : 
  379.  font name
  380. linkicontext(20,WinBlk%,48) : 
  381.  font x size
  382. linkicontext(21,WinBlk%,51) : 
  383.  font y size
  384. linkcseltext(0,WinBlk%,34)  : 
  385.  foreground colour
  386. linkcseltext(1,WinBlk%,37)  : 
  387.  background colour
  388. PWinEdW%=
  389. loadtemplate("WindowEdit",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  390. WinEdTbar%=WinBlk%!76
  391. linkicontext(6,WinBlk%,23)  : 
  392.  window button type
  393. linkcseltext(2,WinBlk%,27)  : 
  394.  title foreground colour
  395. linkcseltext(3,WinBlk%,31)  : 
  396.  title background colour
  397. linkcseltext(4,WinBlk%,35)  : 
  398.  work area foreground colour
  399. linkcseltext(5,WinBlk%,39)  : 
  400.  work area background colour
  401. linkcseltext(6,WinBlk%,43)  : 
  402.  scrollbar inner colour
  403. linkcseltext(7,WinBlk%,47)  : 
  404.  scrollbar outer colour
  405. linkcseltext(8,WinBlk%,51)  : 
  406.  input focus colour
  407. DDefW%=
  408. loadtemplate("DefaultWin",WinBlk%,IndirEnd%,IndirFree%,1)
  409. BSaveW%=
  410. loadtemplate("SaveBox",WinBlk%,IndirEnd%,IndirFree%,1)
  411. GFileName%=WinBlk%!(92+1*32+20)  : 
  412.  pointer to file name in savebox
  413. >SaveFileIcon%=WinBlk%!(92+2*32+20) : 
  414.  draggable file-icon
  415. EIcInfoW%=
  416. loadtemplate("IconInfo",WinBlk%,IndirEnd%,IndirFree%,1)
  417. &IcInfo_Width%=WinBlk%!12-WinBlk%!4
  418. linkicontext(7,WinBlk%,6)   : 
  419.  template name
  420. linkicontext(8,WinBlk%,7)   : 
  421.  icon number
  422. linkicontext(9,WinBlk%,9)   : 
  423.  minimum x coordinate
  424. linkicontext(26,WinBlk%,10) : 
  425.  maximum x coordinate
  426. linkicontext(10,WinBlk%,11) : 
  427.  minimum y coordinate
  428. linkicontext(27,WinBlk%,8)  : 
  429.  maximum y coordinate
  430. linkicontext(11,WinBlk%,12) : 
  431.  icon size
  432. linkicontext(24,WinBlk%,13) : 
  433.  pointer position
  434. CExportW%=
  435. loadtemplate("Export",WinBlk%,IndirEnd%,IndirFree%,1)
  436. EExportName%=WinBlk%!(92+1*32+20)  : 
  437.  pointer to export-file name
  438. @ExportFileIcon%=WinBlk%!(92+2*32+20) : 
  439.  draggable file-icon
  440. MWorkW%=
  441. loadtemplate("WorkArea",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  442. linkicontext(12,WinBlk%,10) : 
  443.  top left X coord
  444. linkicontext(13,WinBlk%,13) : 
  445.  top left Y coord
  446. linkicontext(14,WinBlk%,16) : 
  447.  work area X size
  448. linkicontext(15,WinBlk%,19) : 
  449.  work area Y size
  450. linkicontext(16,WinBlk%,22) : 
  451.  min X size
  452. linkicontext(17,WinBlk%,25) : 
  453.  min Y size
  454. KAlignW%=
  455. loadtemplate("Align",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  456. selecticon(AlignW%,2,1)     : 
  457.  set align-left on
  458. selecticon(AlignW%,8,1)     : 
  459.  move icons
  460. OOptionsW%=
  461. loadtemplate("Options",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  462. OOptPaneW%=
  463. loadtemplate("OptPane",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  464. linkicontext(28,WinBlk%,19) : 
  465.  iconsize grid X size
  466. linkicontext(29,WinBlk%,23) : 
  467.  iconsize grid Y size
  468. linkicontext(30,WinBlk%,28) : 
  469.  iconpos grid X size
  470. linkicontext(31,WinBlk%,32) : 
  471.  iconpos grid Y size
  472.  NSpaceW%=
  473. loadtemplate("Spaceout",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  474. selecticon(SpaceW%,3,1)    : 
  475.  set space-vertically on
  476. selecticon(SpaceW%,4,1)    : 
  477.  set to fixed spacing
  478. linkicontext(18,WinBlk%,6) : 
  479.  space between icons
  480. SpaceOut_Space%=4
  481. seticontext(18,
  482. (SpaceOut_Space%))
  483. space_shadeicons
  484. 'KFrameW%=
  485. loadtemplate("Frame",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  486. linkicontext(32,WinBlk%,7)  : 
  487.  frame icon #
  488. linkicontext(33,WinBlk%,11) : 
  489.  space around icons
  490. linkicontext(34,WinBlk%,17) : 
  491.  label icon #
  492. linkicontext(35,WinBlk%,22) : 
  493.  left space for label
  494. selecticon(FrameW%,6,1)     : 
  495.  use icon for frame
  496. selecticon(FrameW%,15,1)    : 
  497.  no label
  498. selecticon(FrameW%,21,1)    : 
  499.  left-spaced label
  500. Frame_IconNo%=0
  501. Frame_Space%=24
  502. Frame_LabelNo%=0
  503. Frame_LeftSpace%=32
  504. seticontext(33,
  505. (Frame_Space%))
  506. seticontext(35,
  507. (Frame_LeftSpace%))
  508. 5JStatW%=
  509. loadtemplate("Stats",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  510. 64Stat_Colours%=(WinBlk%!(92+5*32+16)) 
  511.  &FF000000
  512. 7EPaletteW%=
  513. loadtemplate("Palette",WinBlk%,IndirEnd%,IndirFree%,1)
  514. 8CDialW%=
  515. loadtemplate("Dialogue",WinBlk%,IndirEnd%,IndirFree%,1)
  516. Dial_Msg%=WinBlk%!(92+20)
  517. :IDial_Button1%=WinBlk%!(92+1*32+20) : 
  518.  pointer to text in left button
  519. ;KDial_Button2%=WinBlk%!(92+2*32+20) : 
  520.  pointer to text in middle button
  521. <JDial_Button3%=WinBlk%!(92+3*32+20) : 
  522.  pointer to text in right button
  523.  store colours and border flag of buttons
  524. >!mask%=(1<<2)+(1<<5)+(&FF<<24)
  525. ?3Dial_ButtonCol1%=(WinBlk%!(92+1*32+16)) 
  526.  mask%
  527. @3Dial_ButtonCol2%=(WinBlk%!(92+2*32+16)) 
  528.  mask%
  529. A3Dial_ButtonCol3%=(WinBlk%!(92+3*32+16)) 
  530.  mask%
  531.  "Wimp_CloseTemplate"
  532.  initialise font usage
  533.  i%=0 
  534.  Fra%?i%>0 
  535. F=    FontUsage%(i%)=1 : 
  536.  font is used by system templates
  537.     FontUsage%(i%)=0
  538. setup_load
  539. readscreenvars
  540. selecticon(OptPaneW%,13,IcInfo_Active%)
  541. selecticon(OptPaneW%,11,DuplNames%)
  542. selecticon(OptPaneW%,12,Hatch%)
  543. selecticon(OptPaneW%,16,Grid_SizeLock%)
  544. seticontext(28,
  545. (Grid_SizeX%))
  546. seticontext(29,
  547. (Grid_SizeY%))
  548. selecticon(OptPaneW%,25,Grid_PosLock%)
  549. seticontext(30,
  550. (Grid_PosX%))
  551. seticontext(31,
  552. (Grid_PosY%))
  553. selecticon(OptPaneW%,14,Save_Unselected%)
  554. selecticon(OptPaneW%,15,DeleteOutside%)
  555. selecticon(OptPaneW%,8,TrapDclick%)
  556. selecticon(OptPaneW%,35,IgnoreDeskFont%)
  557. support(Setup_Support%)
  558. selecticon(StatW%,1,Stats_Decimal%)
  559. selecticon(StatW%,2,
  560.  Stats_Decimal%)
  561. preparemenus
  562.  "OS_ReadModeVariable",27,0 
  563.  ;flg% : 
  564.  test if hires modes available
  565.  (flg% 
  566.  2)=0 
  567.   SprSuffix$="22"
  568.   SprSuffix$=""
  569.  calculate height of title bar
  570. WinBlk%!0=DefW%
  571.  "Wimp_GetWindowState",,WinBlk%
  572. WinBlk%!28=-2
  573.  "Wimp_OpenWindow",,WinBlk%
  574. i%=WinBlk%!12
  575.  "Wimp_GetWindowOutline",,WinBlk%
  576. TBarHeight%=WinBlk%!12-i%
  577.  "Wimp_CloseWindow",,WinBlk%
  578.  get filename that was given as argument with command
  579. fn$,"-quit")
  580.  p%>0 
  581. 34,p%+
  582. ("-quit"))
  583.  p%>0 
  584. 34,p%+1)
  585.  p%>0 
  586.     fn$=
  587. fn$,p%+1)
  588.     p%=
  589. fn$," ")
  590.  p%=0
  591. (fn$)>0 
  592. wA    
  593. templ_loadfile(fn$,1) : 
  594.  found filename - load the file
  595. setmainfname(fn$)
  596. setextent
  597. key(window%,icon%,key%)
  598.  i%,waslast%,dx%,dy%,no%,help$,xmin%,ymin%,xmax%,ymax%,xstep%,ystep%
  599.  (key%=27) 
  600.  (Drag_Type%<>-1) 
  601. abortdrag
  602.  window% 
  603.  IcEdW%
  604.       
  605.  key% 
  606. 0        
  607.  &18E,&18A,13 : 
  608.  down, tab, return
  609.           
  610.  icon%>0 
  611.             i%=icon%
  612.             waslast%=
  613.             
  614.               
  615.  i%=26 
  616.                 i%=23
  617. 5                waslast%=
  618.  caret went "round"
  619.               
  620.                 i%+=1
  621.               
  622. 9            
  623. iconshaded(IcEdW%,i%)) 
  624.  (i%=icon%)
  625. (            
  626.  waslast% 
  627.  (key%=13) 
  628. )              
  629. selecticon(IcEdW%,9,1)
  630. #              
  631. iced_readwin(-1)
  632. )              
  633. selecticon(IcEdW%,9,0)
  634.               i%=icon%
  635.             
  636. $            
  637. setcaret(IcEdW%,i%)
  638.           
  639. )        
  640.  &18F,&19A : 
  641.  up, shift+tab
  642.           
  643.  icon%>0 
  644.             i%=icon%
  645.             
  646.               
  647.  i%=23 
  648.                 i%=26
  649.               
  650.                 i%-=1
  651.               
  652. 9            
  653. iconshaded(IcEdW%,i%)) 
  654.  (i%=icon%)
  655. $            
  656. setcaret(IcEdW%,i%)
  657.           
  658.         
  659.  &181 : 
  660. 0          
  661.  "Wimp_GetPointerInfo",,PtrInfo%
  662. $          
  663.  PtrInfo%!12=IcEdW% 
  664.             help$=""
  665.              
  666.  PtrInfo%!16 
  667. 6              
  668.  14            : help$="Indirected"
  669. 6              
  670.  3,25          : help$="Validation"
  671. 3              
  672.  4,26          : help$="Maxsize"
  673. 2              
  674.  15            : help$="Border"
  675. 2              
  676.  16            : help$="Filled"
  677. 4              
  678.  17            : help$="Hcentred"
  679. 4              
  680.  18            : help$="Vcentred"
  681. 6              
  682.  19            : help$="Rjustified"
  683. 5              
  684.  20            : help$="Needshelp"
  685. 7              
  686.  21            : help$="Allowadjust"
  687. 4              
  688.  22            : help$="Halfsize"
  689. 6              
  690.  5,27,28,29    : help$="Buttontype"
  691. /              
  692.  6,30,31,32    : help$="ESG"
  693. 2              
  694.  39            : help$="Shaded"
  695. 1              
  696.  7,33,34,35    : help$="Fgcol"
  697. 1              
  698.  8,36,37,38    : help$="Bgcol"
  699. 0              
  700.  41            : help$="Font"
  701. 1              
  702.  1             : help$="Flags"
  703.             
  704.             
  705.  help$<>"" 
  706. 5              
  707. askhelp("TemplEd.IconInfo_"+help$)
  708.             
  709.           
  710.         
  711.  &182 : 
  712. %          
  713. selecticon(IcEdW%,9,1)
  714.           
  715. iced_readwin(-1)
  716. %          
  717. selecticon(IcEdW%,9,0)
  718.         
  719.  &183 : 
  720. &          
  721. selecticon(IcEdW%,10,1)
  722.           
  723. iced_readwin(-1)
  724. &          
  725. selecticon(IcEdW%,10,0)
  726. "          
  727. closewindow(IcEdW%)
  728. %          
  729. setcaret(IcEd_Win%,-1)
  730. !        
  731.  &184,27 : 
  732.  F4, Esc
  733. &          
  734. selecticon(IcEdW%,11,1)
  735. "          
  736. closewindow(IcEdW%)
  737. &          
  738. selecticon(IcEdW%,11,0)
  739. %          
  740. setcaret(IcEd_Win%,-1)
  741.         
  742. '          
  743.  "Wimp_ProcessKey",key%
  744.       
  745.  WinEdW%
  746.       
  747.  key% 
  748.         
  749.  &181     
  750. 0          
  751.  "Wimp_GetPointerInfo",,PtrInfo%
  752. %          
  753.  PtrInfo%!12=WinEdW% 
  754.             help$=""
  755.              
  756.  PtrInfo%!16 
  757. 4              
  758.  4             : help$="Moveable"
  759. 7              
  760.  5             : help$="Auto-redraw"
  761. 3              
  762.  6             : help$="Hotkeys"
  763. 0              
  764.  7             : help$="Pane"
  765. 4              
  766.  8             : help$="Nobounds"
  767. 0              
  768.  9             : help$="GCOL"
  769. 6              
  770.  10            : help$="Backwindow"
  771. 6              
  772.  1,21,22,23,24 : help$="Buttontype"
  773. 5              
  774.  20            : help$="Newformat"
  775. 4              
  776.  57            : help$="OnScreen"
  777. 2              
  778.  11,58,59,60   : help$="Scroll"
  779. 4              
  780.  12,61,62,63   : help$="NoExtent"
  781.             
  782.             
  783.  help$<>"" 
  784. 4              
  785. askhelp("TemplEd.WinInfo_"+help$)
  786.             
  787.           
  788.         
  789.  &182,13
  790. '          
  791. selecticon(WinEdW%,53,1)
  792.           
  793. wined_readwin
  794. '          
  795. selecticon(WinEdW%,53,0)
  796.         
  797.  &183
  798. '          
  799. selecticon(WinEdW%,54,1)
  800.           
  801. wined_readwin
  802. '          
  803. selecticon(WinEdW%,54,0)
  804. #          
  805. closewindow(WinEdW%)
  806. &          
  807. setcaret(WinEd_Win%,-1)
  808.         
  809.  &184,27
  810. '          
  811. selecticon(WinEdW%,55,1)
  812. #          
  813. closewindow(WinEdW%)
  814. '          
  815. selecticon(WinEdW%,55,0)
  816. &          
  817. setcaret(WinEd_Win%,-1)
  818.         
  819. '          
  820.  "Wimp_ProcessKey",key%
  821.       
  822.  SaveW%
  823.       
  824.  key% 
  825.         
  826. %          
  827. selecticon(SaveW%,0,1)
  828.           
  829.  Exporting% 
  830. .            
  831. exporttemplates($(FileName%))
  832.           
  833. $            
  834.  SavingSelection% 
  835. (              SelFname$=$(FileName%)
  836. +              
  837. savetemplates(SelFname$)
  838.             
  839. -              
  840. setmainfname($(FileName%))
  841. ,              
  842. savetemplates(MainFname$)
  843.             
  844.           
  845. %          
  846. selecticon(SaveW%,0,0)
  847. &          
  848.  "Wimp_CreateMenu",,-1
  849.         
  850. '          
  851.  "Wimp_ProcessKey",key%
  852.       
  853.  ExportW%
  854.       
  855.  key% 
  856.         
  857. '          
  858. selecticon(ExportW%,0,1)
  859. /          
  860. export_savenames($(ExportName%))
  861. '          
  862. selecticon(ExportW%,0,0)
  863. &          
  864.  "Wimp_CreateMenu",,-1
  865.         
  866. '          
  867.  "Wimp_ProcessKey",key%
  868.       
  869.  WorkW%
  870.       
  871.  key% 
  872.         
  873.  &18E,&18A,13
  874.           
  875.  icon%=25 
  876.             
  877.  key%=13 
  878. "*              
  879. selecticon(WorkW%,30,1)
  880.               
  881. setworkarea
  882. $*              
  883. selecticon(WorkW%,30,0)
  884. %*              
  885.  "Wimp_CreateMenu",,-1
  886.             
  887. '&              
  888. setcaret(WorkW%,10)
  889.             
  890.           
  891. *)            
  892. setcaret(WorkW%,icon%+3)
  893.           
  894.         
  895.  &18F,&19A
  896.           
  897.  icon%=10 
  898. .$            
  899. setcaret(WorkW%,25)
  900.           
  901. 0)            
  902. setcaret(WorkW%,icon%-3)
  903.           
  904.         
  905. 3&          
  906.  "Wimp_CreateMenu",,-1
  907.         
  908. 5'          
  909.  "Wimp_ProcessKey",key%
  910.       
  911.  SpaceW%
  912.       
  913.  key%=13 
  914. 9$        
  915. selecticon(SpaceW%,9,1)
  916. :&        
  917. spaceicons(LastMenu_Win%)
  918. ;$        
  919. selecticon(SpaceW%,9,0)
  920. <$        
  921.  "Wimp_CreateMenu",,-1
  922.       
  923. >%        
  924.  "Wimp_ProcessKey",key%
  925.       
  926.  FrameW%
  927.       
  928.  key%=13 
  929. B$        
  930. selecticon(FrameW%,3,1)
  931. C$        
  932.  "Wimp_CreateMenu",,-1
  933. D&        
  934. frameicons(LastMenu_Win%)
  935. E$        
  936. selecticon(FrameW%,3,0)
  937.       
  938. G%        
  939.  "Wimp_ProcessKey",key%
  940.       
  941. I        
  942.       
  943.  Drag_Type% 
  944.         
  945.  0,1,5,6,7
  946.           dx%=0
  947.           dy%=0
  948.           
  949.  key% 
  950. O(            
  951.  &18C : dx%=-PixToOS_X%
  952. P'            
  953.  &18D : dx%=PixToOS_X%
  954. Q(            
  955.  &18E : dy%=-PixToOS_Y%
  956. R'            
  957.  &18F : dy%=PixToOS_Y%
  958. S*            
  959.  &19C : dx%=-4*PixToOS_X%
  960. T)            
  961.  &19D : dx%=4*PixToOS_X%
  962. U*            
  963.  &19E : dy%=-4*PixToOS_Y%
  964. V)            
  965.  &19F : dy%=4*PixToOS_Y%
  966. W-            
  967.  "Wimp_ProcessKey",key%
  968.           
  969. Y0          
  970.  "Wimp_GetPointerInfo",,PtrInfo%
  971. Z4          
  972.  (PtrInfo%!0)+dx%,(PtrInfo%!4)+dy%
  973.         
  974. \)          no%=
  975. whichtemplate(window%)
  976.           
  977.  no%>=0 
  978.             
  979.  key% 
  980. _@              
  981.  1        : 
  982. sel_all(window%)          : 
  983.               
  984.                 dummy%=-1
  985. bC                
  986. copyiconsel(window%,dummy%,0)           : 
  987.               
  988.                 dummy%=-1
  989. eC                
  990. copyiconsel(window%,dummy%,2)           : 
  991. f@              
  992.  5       : 
  993. iced_start(window%,-1)     : 
  994.               
  995. hC                
  996. sel_get(window%)                        : 
  997. i&                
  998.  NrSelected%>=2 
  999. j$                  
  1000. frame_fillwin
  1001. k<                  
  1002. createwinmenu(window%,FrameW%,-80,80)
  1003.                 
  1004.               
  1005. nC                
  1006. sel_get(window%)                        : 
  1007. o&                
  1008.  NrSelected%>=2 
  1009. p<                  
  1010. createwinmenu(window%,AlignW%,-80,80)
  1011.                 
  1012.               
  1013. sC                
  1014. sel_get(window%)                        : 
  1015. t&                
  1016.  NrSelected%>=2 
  1017. u<                  
  1018. createwinmenu(window%,SpaceW%,-80,80)
  1019.                 
  1020.               
  1021.                 dummy%=-1
  1022. yC                
  1023. copyiconsel(window%,dummy%,3)           : 
  1024. zD              
  1025.  17,&1A2 : 
  1026. closetemplate(no%)         : 
  1027.  ^Q,^F2
  1028.               
  1029.                 dummy%=-1
  1030. }C                
  1031. copyiconsel(window%,dummy%,4)           : 
  1032. ~@              
  1033.  20      : 
  1034. iced_start(window%,-4)     : 
  1035.               
  1036.                 dummy%=-1
  1037. C                
  1038. copyiconsel(window%,dummy%,1)           : 
  1039. @              
  1040.  23      : 
  1041. wined_fillwin(window%)     : 
  1042. @              
  1043.  24      : 
  1044. deleteiconsel(window%,-1)  : 
  1045. @              
  1046.  26      : 
  1047. sel_clear(window%,-1)      : 
  1048. ;              
  1049.  &18C,&18D,&18E,&18F,&19C,&19D,&19E,&19F
  1050. %                
  1051. sel_get(window%)
  1052. %                
  1053.  NrSelected%>0 
  1054. ?                  
  1055. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  1056. '                  
  1057.  Grid_PosLock% 
  1058. )                    xstep%=Grid_PosX%
  1059. )                    ystep%=Grid_PosY%
  1060.                   
  1061. *                    
  1062.  Grid_SizeLock% 
  1063. ,                      xstep%=Grid_SizeX%
  1064. ,                      ystep%=Grid_SizeY%
  1065.                     
  1066. +                      xstep%=PixToOS_X%
  1067. +                      ystep%=PixToOS_Y%
  1068.                     
  1069.                   
  1070. &                  
  1071.  (key% 
  1072.  &F) 
  1073. *                    
  1074.  &C : dx%=-xstep%
  1075. )                    
  1076.  &D : dx%=xstep%
  1077. *                    
  1078.  &E : dy%=-ystep%
  1079. )                    
  1080.  &F : dy%=ystep%
  1081.                   
  1082. $                  
  1083.  key% 
  1084.  &10 
  1085. !                    dx%=dx%*4
  1086. !                    dy%=dy%*4
  1087.                   
  1088.                    xmin%+=dx%
  1089.                    xmax%+=dx%
  1090.                    ymin%+=dy%
  1091.                    ymax%+=dy%
  1092. M                  
  1093. moveresize(window%,-1,window%,xmin%,ymin%,xmax%,ymax%)
  1094.                 
  1095. 2              
  1096.     : 
  1097.  "Wimp_ProcessKey",key%
  1098.             
  1099.           
  1100. )            
  1101.  "Wimp_ProcessKey",key%
  1102.           
  1103.       
  1104. loadtemplate(name$,buf%,
  1105.  indir%,
  1106.  free%,spptr%)
  1107.  oldindir%,handle%
  1108.  "Wimp_CloseTemplate" : 
  1109. error(1)
  1110. oldindir%=indir%
  1111. name$=name$+
  1112.  "Wimp_LoadTemplate",,buf%+4,indir%,indir%+free%,Fra%,name$,0 
  1113.  ,,indir%
  1114. free%-=(indir%-oldindir%)
  1115. buf%!68=spptr%
  1116.  buf%!88>0 
  1117.  i%=0 
  1118.  buf%!88
  1119.     f%=buf%!(92+i%*32+16)
  1120.  (f% 
  1121.  &103)=&102 
  1122. #      buf%!(92+i%*32+24)=spptr%
  1123.         
  1124.  "Wimp_CreateWindow",,buf%+4 
  1125.  handle%
  1126. buf%!0=handle%
  1127. =handle%
  1128. menuselect(selection%)
  1129.  adjust%,selinfo%,itemnr%,item%,item$,parentitem%,parentitem$
  1130.  cmd$,i%,j%,minx%,miny%,size,dir%
  1131.  "MenuUtil_Decode",LastMenu%,selection% 
  1132.  ,adjust%,selinfo%
  1133. itemnr%=selinfo%!0
  1134. item%=selinfo%!8
  1135. item$=
  1136. str(selinfo%!12)
  1137. parentitem%=selinfo%!24
  1138.  parentitem%<>0 
  1139.  parentitem$=
  1140. str(selinfo%!28)
  1141.  LastMenu% 
  1142.  MainMenu%
  1143.  item% 
  1144.       
  1145.  item_help%
  1146. ,        
  1147. modulepresent("StrongHelp") 
  1148. C          
  1149.  "Wimp_StartTask","Filer_Run <TemplEd$Dir>.TemplEd"
  1150.         
  1151.           
  1152. dialogue(5,"")
  1153.         
  1154.       
  1155.  item_options%
  1156. $        
  1157. openwindow(OptionsW%,2)
  1158.       
  1159.  item_stats%
  1160.         
  1161. stat_fillwin
  1162. -      
  1163.  item_customsprites%,item_sprview%
  1164.         
  1165.  UserSprites%<>1 
  1166. &          cmd$="Run "+SpriteFname$
  1167. 4          
  1168.  OSversion%>=300 
  1169.  cmd$="Filer_"+cmd$
  1170.           
  1171.  cmd$
  1172.         
  1173.       
  1174.  item_sprreload%
  1175. *        
  1176. loadusersprites(SpriteFname$)
  1177.       
  1178.  item_sprreset%
  1179.          
  1180. loadusersprites("")
  1181.       
  1182.  item_quit%
  1183.         
  1184.  ChangesMade% 
  1185.           
  1186. dialogue(0,"")
  1187.         
  1188.           
  1189. prequit
  1190.         
  1191.         
  1192.  TemplMenu%
  1193.  item% 
  1194.       
  1195.  item_templname%
  1196.         
  1197.  parentitem% 
  1198. !          
  1199.  item_createtempl%
  1200.             
  1201. (item$)>0 
  1202. !              WinBlk%!0=DefW%
  1203. 2              
  1204.  "Wimp_GetWindowInfo",,WinBlk%
  1205. J              $(WinBlk%+76)=item$ : 
  1206.  title bar equal to template name
  1207.               WinBlk%!88=0
  1208. -              
  1209. templ_add(item$,WinBlk%,1)
  1210. /              
  1211. opentemplate(NrTemplates%-1)
  1212.                
  1213. setchanged(
  1214.             
  1215. !          
  1216.  item_renametempl%
  1217.             
  1218. (item$)>0 
  1219.               j%=0
  1220. 0              
  1221.  check if name already exists
  1222. F              
  1223.  (j%<NrTemplates%) 
  1224.  ($(TemplNames%+28*j%)<>item$)
  1225.                 j%+=1
  1226.               
  1227. 4              
  1228.  (j%=NrTemplates%) 
  1229.  DuplNames% 
  1230.                  i%=SelBlk%!0
  1231. .                $(TemplNames%+28*i%)=item$
  1232. &                IconBlk%!0=TemplW%
  1233. !                IconBlk%!4=i%
  1234. 4                
  1235.  "Wimp_GetIconState",,IconBlk%
  1236. O                IconBlk%!16=(IconBlk%!8)+(TemplW_IconX%-8)-16*(11-
  1237. (item$))
  1238. =                dummy%=
  1239. redefineicon(TemplW%,i%,IconBlk%)
  1240. "                
  1241. setchanged(
  1242.               
  1243. 3                
  1244. complain(
  1245. msg_lookup0("TAEX"))
  1246.               
  1247.             
  1248.           
  1249.  item_copytempl%
  1250.             
  1251. (item$)>0 
  1252. #              
  1253. sel_get(TemplW%)
  1254. 8              WinBlk%!0=TemplHandle%!(4*(SelBlk%!0))
  1255. 2              
  1256.  "Wimp_GetWindowInfo",,WinBlk%
  1257. 0              
  1258.  PaneFlag%?(SelBlk%!(4*i%)) 
  1259. G                WinBlk%!32=WinBlk%!32 
  1260.  (1<<5) : 
  1261.  copy 'Pane' flag
  1262.               
  1263. 5              
  1264. iconrealloc(WinBlk%+60,WinBlk%+76)
  1265. "              
  1266.  WinBlk%!88>0 
  1267. )                
  1268.  i%=0 
  1269.  WinBlk%!88-1
  1270. K                  
  1271. iconrealloc(WinBlk%+92+32*i%+16,WinBlk%+92+32*i%+20)
  1272.                 
  1273.               
  1274. -              
  1275. templ_add(item$,WinBlk%,1)
  1276. /              
  1277. opentemplate(NrTemplates%-1)
  1278.                
  1279. setchanged(
  1280.             
  1281.         
  1282.       
  1283.  item_opentempl%
  1284.         
  1285. sel_get(TemplW%)
  1286. "'        
  1287.  i%=NrSelected%-1 
  1288. #+          
  1289. opentemplate(SelBlk%!(4*i%))
  1290.         
  1291.       
  1292.  item_closetempl%
  1293.         
  1294. sel_get(TemplW%)
  1295. ''        
  1296.  i%=NrSelected%-1 
  1297. (,          
  1298. closetemplate(SelBlk%!(4*i%))
  1299.         
  1300.       
  1301.  item_deletetempl%
  1302.         
  1303.  "Hourglass_On"
  1304.         
  1305. sel_get(TemplW%)
  1306. -'        
  1307.  i%=NrSelected%-1 
  1308. .+          
  1309. templ_delete(SelBlk%!(4*i%))
  1310.         
  1311. 0"        
  1312. sel_clear(TemplW%,-1)
  1313. 1!        LastMenu_Win%=TemplW%
  1314.         LastMenu_Icon%=-1
  1315.         
  1316.  "Hourglass_Off"
  1317.       
  1318.  item_selalltempl%
  1319.         
  1320. sel_all(TemplW%)
  1321. 6!        TemplMenu_Deselect%=
  1322.       
  1323.  item_clearseltempl%
  1324. 8"        
  1325. sel_clear(TemplW%,-1)
  1326. 9!        TemplMenu_Deselect%=
  1327.       
  1328.  item_deleteall%
  1329.         
  1330.  ChangesMade% 
  1331.           
  1332. dialogue(1,"")
  1333.         
  1334.           
  1335. templ_deleteall
  1336. ?#          LastMenu_Win%=TemplW%
  1337.           LastMenu_Icon%=-1
  1338.         
  1339.       
  1340.  item_sorttempl%
  1341. C"        
  1342. sel_clear(TemplW%,-1)
  1343.         
  1344. templ_sort
  1345.         
  1346. redefinebrowser(
  1347. F!        LastMenu_Win%=TemplW%
  1348.         LastMenu_Icon%=-1
  1349.       
  1350.  item_save%
  1351.         SavingSelection%=
  1352. J&        
  1353. savetemplates(MainFname$)
  1354. K        
  1355. L6    
  1356.  TemplMenu_Deselect% 
  1357. sel_clear(TemplW%,-1)
  1358.  UserMenu%
  1359.  item% 
  1360. OE      
  1361.  item_copyicon%,item_up%,item_down%,item_left%,item_right%
  1362.         
  1363.  item% 
  1364. Q'          
  1365.  item_copyicon% : dir%=0
  1366. R'          
  1367.  item_up%       : dir%=1
  1368. S'          
  1369.  item_down%     : dir%=2
  1370. T'          
  1371.  item_left%     : dir%=3
  1372. U'          
  1373.  item_right%    : dir%=4
  1374.         
  1375. W;        
  1376. copyiconsel(LastMenu_Win%,LastMenu_Icon%,dir%)
  1377. X+      
  1378.  item_iconnr%,item_renumbericon%
  1379. Y7        
  1380.  item%=item_iconnr% 
  1381.  NextIconNr%=
  1382. (item$)
  1383. Z#        
  1384. sel_get(LastMenu_Win%)
  1385.         
  1386.  NrSelected% 
  1387.           
  1388. ];            
  1389. renumbericon(LastMenu_Win%,LastMenu_Icon%)
  1390. ^*            LastMenu_Icon%=NextIconNr%
  1391.             NextIconNr%+=1
  1392.           
  1393. a6            
  1394. renumbericon(LastMenu_Win%,SelBlk%!0)
  1395.           
  1396. c/            
  1397. renumbericonsel(LastMenu_Win%)
  1398.         
  1399.       
  1400.  item_deleteicon%
  1401. f8        
  1402. deleteiconsel(LastMenu_Win%,LastMenu_Icon%)
  1403.       
  1404.  item_editicon%
  1405. h5        
  1406. iced_start(LastMenu_Win%,LastMenu_Icon%)
  1407.       
  1408.  item_minsize%
  1409. j<        
  1410. minimizeiconsel(LastMenu_Win%,LastMenu_Icon%,0)
  1411.       
  1412.  item_centericon%
  1413. l:        
  1414. centericonsel(LastMenu_Win%,LastMenu_Icon%,0)
  1415.       
  1416.  item_samesize%
  1417. n<        
  1418. samesizeiconsel(LastMenu_Win%,LastMenu_Icon%,0)
  1419. o,      
  1420.  item_both%,item_xdim%,item_ydim%
  1421.         
  1422.  parentitem% 
  1423.           
  1424.  item_minsize%
  1425. rF            
  1426. minimizeiconsel(LastMenu_Win%,LastMenu_Icon%,itemnr%)
  1427. s           
  1428.  item_centericon%
  1429. tD            
  1430. centericonsel(LastMenu_Win%,LastMenu_Icon%,itemnr%)
  1431.           
  1432.  item_samesize%
  1433. vF            
  1434. samesizeiconsel(LastMenu_Win%,LastMenu_Icon%,itemnr%)
  1435.         
  1436.       
  1437.  item_selallicons%
  1438. y#        
  1439. sel_all(LastMenu_Win%)
  1440.       
  1441.  item_clearselicons%
  1442. {(        
  1443. sel_clear(LastMenu_Win%,-1)
  1444.       
  1445.  item_editwindow%
  1446. })        
  1447. wined_fillwin(LastMenu_Win%)
  1448.       
  1449.  item_edittitle%
  1450. )        
  1451. iced_start(LastMenu_Win%,-4)
  1452.       
  1453.  item_tidy1%
  1454. 5        LastMenu_Win%=
  1455. tidyicons(LastMenu_Win%,1)
  1456.       
  1457.  item_tidy2%
  1458. 5        LastMenu_Win%=
  1459. tidyicons(LastMenu_Win%,2)
  1460.       
  1461.  item_tidy3%
  1462. 5        LastMenu_Win%=
  1463. tidyicons(LastMenu_Win%,3)
  1464.       
  1465.  item_tidy4%
  1466. 5        LastMenu_Win%=
  1467. tidyicons(LastMenu_Win%,4)
  1468.       
  1469.  item_tidy5%
  1470. 5        LastMenu_Win%=
  1471. tidyicons(LastMenu_Win%,5)
  1472.       
  1473.  item_centerwin%
  1474. (        
  1475. openwindow(LastMenu_Win%,1)
  1476.       
  1477.  item_wimparea%
  1478. 2        
  1479. window_setspritearea(LastMenu_Win%,1)
  1480.       
  1481.  item_customarea%
  1482. =        
  1483. window_setspritearea(LastMenu_Win%,UserSprites%)
  1484.       
  1485.  item_closewin%
  1486. 9        
  1487. closetemplate(
  1488. whichtemplate(LastMenu_Win%))
  1489.       
  1490.  item_createicon%
  1491. $        
  1492. openwindow(PaletteW%,0)
  1493.         
  1494.  IcButtonMenu%
  1495.     IcEd_Button%=itemnr%
  1496. 4    
  1497. seticontext(4,$(IcButton%+20*IcEd_Button%))
  1498.  WinButtonMenu%
  1499.     WinEd_Button%=itemnr%
  1500. 6    
  1501. seticontext(6,$(WinButton%+20*WinEd_Button%))
  1502.  EsgMenu%
  1503.     IcEd_Esg%=
  1504. item$,2))
  1505. $    
  1506. seticontext(5,
  1507. (IcEd_Esg%))
  1508.  ColourMenu%
  1509.  item$="None" 
  1510.       j%=255
  1511.         
  1512.       j%=
  1513. (item$)
  1514.         
  1515.  LastMenu_Win% 
  1516.       
  1517.  IcEdW%
  1518.         
  1519.  LastMenu_Icon% 
  1520.           
  1521.             IcEd_Fgcol%=j%
  1522. #            
  1523. setcolourbox(0,j%)
  1524.           
  1525.             IcEd_Bgcol%=j%
  1526. #            
  1527. setcolourbox(1,j%)
  1528.         
  1529.       
  1530.  WinEdW%
  1531. &        i%=(LastMenu_Icon%-27) 
  1532.         WinEd_Col%(i%)=j%
  1533. "        
  1534. setcolourbox(2+i%,j%)
  1535.         
  1536.  FontMenu%
  1537. (parentitem$)>0 
  1538.       
  1539.  item$="(Regular)" 
  1540. "        IcEd_Font$=parentitem$
  1541.       
  1542. ,        IcEd_Font$=parentitem$+"."+item$
  1543.       
  1544. %      
  1545. seticontext(19,IcEd_Font$)
  1546.         
  1547.  FontSizemenu%
  1548.     size=
  1549. (item$)
  1550.  size>0 
  1551.       
  1552.  LastMenu_Icon%=48 
  1553.         IcEd_Xsize=size
  1554. .        
  1555. seticontext(20,
  1556. (IcEd_Xsize),4))
  1557. (        
  1558. iconselected(IcEdW%,53) 
  1559. #          IcEd_Ysize=IcEd_Xsize
  1560. 0          
  1561. seticontext(21,
  1562. (IcEd_Ysize),4))
  1563.         
  1564.       
  1565.         IcEd_Ysize=size
  1566. .        
  1567. seticontext(21,
  1568. (IcEd_Ysize),4))
  1569.       
  1570.         
  1571.  Updatemenu%
  1572.  item% 
  1573. 1      
  1574.  item_updbt%   : 
  1575. iced_readwin(&F<<12)
  1576. 2      
  1577.  item_updesg%  : 
  1578. iced_readwin(&1F<<16)
  1579. :      
  1580.  item_updfg%   : 
  1581. iced_readwin((&F<<24)+(1<<6))
  1582. :      
  1583.  item_updbg%   : 
  1584. iced_readwin((&F<<28)+(1<<6))
  1585. ;      
  1586.  item_updfont% : 
  1587. iced_readwin((&FF<<24)+(1<<6))
  1588. 7      
  1589.  item_updrest% : 
  1590. iced_readwin(&EFC+(1<<22))
  1591. /      
  1592.  item_updbo%:  : 
  1593. iced_readwin(1<<2)
  1594. /      
  1595.  item_updfi%:  : 
  1596. iced_readwin(1<<5)
  1597. /      
  1598.  item_updhc%:  : 
  1599. iced_readwin(1<<3)
  1600. /      
  1601.  item_updvc%:  : 
  1602. iced_readwin(1<<4)
  1603. /      
  1604.  item_updrj%:  : 
  1605. iced_readwin(1<<9)
  1606. /      
  1607.  item_updnh%:  : 
  1608. iced_readwin(1<<7)
  1609. 0      
  1610.  item_updaa%:  : 
  1611. iced_readwin(1<<10)
  1612. 0      
  1613.  item_updhs%:  : 
  1614. iced_readwin(1<<11)
  1615. 0      
  1616.  item_updsh%:  : 
  1617. iced_readwin(1<<22)
  1618.         
  1619.  LastMenu_Icon%=10 
  1620.       
  1621. closewindow(IcEdW%)
  1622. !      
  1623. setcaret(IcEd_Win%,-1)
  1624.       adjust%=
  1625.         
  1626.  adjust% 
  1627. createmenu(LastMenu_X%,LastMenu_Y%,LastMenu_Win%,LastMenu_Icon%)
  1628.   LastMenu%=-1
  1629. editaction(xpos%,ypos%,button%,window%,icon%,no%)
  1630.  key%,dclick%
  1631. key%=0
  1632. dclick%=
  1633.  -1) 
  1634.  key%+=1 : 
  1635.  bit 0 -> Shift key
  1636.  -2) 
  1637.  key%+=2 : 
  1638.  bit 1 -> Ctrl key
  1639.  -3) 
  1640.  key%+=4 : 
  1641.  bit 2 -> Alt key
  1642. +TimedDrag_Enabled%=(key%=0)
  1643. (icon%>=-1)
  1644.  button%>256 
  1645. @  button%=button%>>8 : 
  1646.  clicked on icon with button type 10
  1647.  key% 
  1648.  0 : 
  1649.  mouse button, no key
  1650.  button%>0 
  1651. 4      dclick%=(
  1652. -ThisClickTime%)<DclickInterval%
  1653. A      dclick%=dclick% 
  1654.  (ThisClickButton%=button%) 
  1655.  (no%>=0)
  1656. J      dclick%=dclick% 
  1657. (ThisClickX%-xpos%)+
  1658. (ThisClickY%-ypos%))<32
  1659.       ThisClickTime%=
  1660.       ThisClickX%=xpos%
  1661.       ThisClickY%=ypos%
  1662. "      ThisClickButton%=button%
  1663.         
  1664.  button% 
  1665.       
  1666.         
  1667.  icon% 
  1668.           
  1669. 7            
  1670.  dclick% 
  1671.  TrapDclick% 
  1672.  (button%=4) 
  1673. ,              
  1674. iced_start(window%,icon%)
  1675.             
  1676.           
  1677. 4            
  1678.  button%=4 
  1679. sel_clear(window%,-1)
  1680.     7            
  1681.  dclick% 
  1682.  TrapDclick% 
  1683.  (button%=4) 
  1684. )              
  1685. wined_fillwin(window%)
  1686.             
  1687. &              
  1688. dragselect(button%)
  1689. 2              
  1690.  no%>=0 
  1691. setcaret(window%,-1)
  1692.             
  1693.           
  1694.             
  1695.  icon%>=0 
  1696.               
  1697.  button%=1 
  1698. -                
  1699.  toggle "selected" state
  1700. '                ScrapBlk%!0=window%
  1701. %                ScrapBlk%!4=icon%
  1702. 5                
  1703.  "Wimp_GetIconState",,ScrapBlk%
  1704. 2                
  1705.  ((ScrapBlk%!24)>>12) 
  1706. M                  
  1707.  4,9      : 
  1708.  selecting useless for these button types
  1709. ;                  
  1710.  5,7,8,11 : 
  1711.  selecting done by wimp
  1712. <                  
  1713. seticonstate(window%,icon%,1<<21,0)
  1714.                 
  1715.               
  1716. (                
  1717.  "exclusive" select
  1718. -                
  1719. sel_clear(window%,icon%)
  1720. 6                
  1721. iconselected(window%,icon%) 
  1722. 2                  
  1723. selecticon(window%,icon%,1)
  1724.                 
  1725.               
  1726. "9              
  1727.  dclick% 
  1728.  TrapDclick% 
  1729.  (button%=4) 
  1730. #.                
  1731. iced_start(window%,icon%)
  1732.               
  1733. %(                
  1734. dragselect(button%)
  1735. &4                
  1736.  no%>=0 
  1737. setcaret(window%,-1)
  1738.               
  1739.             
  1740.         
  1741. *        
  1742.  1 : 
  1743.  shift + mouse button
  1744.  button% 
  1745.       
  1746. .,        
  1747.  no%>=0 
  1748. setcaret(window%,-1)
  1749. /&        
  1750.  (no%>=0) 
  1751.  (button%=4) 
  1752. 03          
  1753. starticondrag(button%,window%,icon%)
  1754.         
  1755.       
  1756. 31        
  1757.  no%>=0 
  1758. iced_start(window%,icon%)
  1759. 4        
  1760.  2 : 
  1761.  ctrl + mouse button
  1762.  button% 
  1763.       
  1764.         
  1765.  no%>=0 
  1766. 9#          
  1767. setcaret(window%,-1)
  1768. :)          
  1769. startwindowresize(window%)
  1770.         
  1771.       
  1772.         
  1773.  no%>=0 
  1774.           
  1775.  icon%=-4 
  1776. ?*            
  1777. iced_start(window%,icon%)
  1778.           
  1779. A'            
  1780. wined_fillwin(window%)
  1781.           
  1782.         
  1783.       
  1784.         
  1785.  no%>=0 
  1786. F#          
  1787. setcaret(window%,-1)
  1788. G'          
  1789. startwindowmove(window%)
  1790.         
  1791. I        
  1792.  4 : 
  1793.  alt + mouse button
  1794.  button% 
  1795.       
  1796. M%        
  1797.  (icon%>=0) 
  1798.  (no%>=0) 
  1799. N*          
  1800. renumbericon(window%,icon%)
  1801. O.          
  1802.  NextIconNr%>0 
  1803.  NextIconNr%-=1
  1804.         
  1805.       
  1806. R%        
  1807.  (icon%>=0) 
  1808.  (no%>=0) 
  1809. S*          
  1810. renumbericon(window%,icon%)
  1811.           NextIconNr%+=1
  1812.         
  1813. V        
  1814.  6 : 
  1815.  alt + ctrl + mouse button
  1816.  button% 
  1817.       
  1818. Z6        
  1819.  (no%>=0) 
  1820. startworkarearesize(window%)
  1821. [        
  1822.  (button%>0) 
  1823.       
  1824.  Support% 
  1825. _%        
  1826.  1 : 
  1827.  support Interface
  1828.           
  1829.  invert icon
  1830. a!          ScrapBlk%!8=button%
  1831. b"          ScrapBlk%!12=window%
  1832. c           ScrapBlk%!16=icon%
  1833. d-          
  1834.  "Wimp_BorderIcon",,ScrapBlk%
  1835.           
  1836.  back to normal
  1837.           ScrapBlk%!8=0
  1838. g"          ScrapBlk%!12=window%
  1839. h           ScrapBlk%!16=icon%
  1840. i-          
  1841.  "Wimp_BorderIcon",,ScrapBlk%
  1842.         
  1843.  2 : 
  1844.  support AEH
  1845. k!          ScrapBlk%!8=button%
  1846. l"          ScrapBlk%!12=window%
  1847. m           ScrapBlk%!16=icon%
  1848. n,          
  1849.  "AEH_RedrawIcon",,ScrapBlk%
  1850. o$          
  1851.  "AEH_ReleaseIcon",0
  1852. p#        
  1853.  3 : 
  1854.  support WimpExt
  1855. q3          
  1856.  "WimpExt_SlabIcon",,,window%,icon%
  1857. r%        
  1858.  4 : 
  1859.  support Sculptrix
  1860. s7          
  1861.  "Sculptrix_SetSpriteArea",UserSprites%
  1862. t=          
  1863.  "Sculptrix_SlabIcon",window%,icon%,ScrapBlk%
  1864. u3          
  1865.  "Sculptrix_UnslabIcon",,,ScrapBlk%
  1866.       
  1867. w        
  1868. click(xpos%,ypos%,button%,window%,icon%,wimpclick%)
  1869.  no%,key%
  1870. }"Mbuttons_Released%=(button%=0)
  1871. TimedDrag_Enabled%=
  1872. whichtemplate(window%)
  1873.  button%=2 
  1874.  "steal" clicks with Menu if Shift, Ctrl or Alt pressed
  1875.  "OS_Byte",121,0 
  1876.  ,key%
  1877.  key%>=3 
  1878. =    
  1879.  wimpclick% 
  1880. createmenu(xpos%,ypos%,window%,icon%)
  1881. F    
  1882.  no%<>-1 
  1883. editaction(xpos%,ypos%,button%,window%,icon%,no%)
  1884.  no%<>-1 
  1885. :    
  1886. editaction(xpos%,ypos%,button%,window%,icon%,no%)
  1887. D    
  1888.  wimpclick% 
  1889. iconclick(xpos%,ypos%,button%,window%,icon%)
  1890. iconclick(xpos%,ypos%,button%,window%,icon%)
  1891.  select%,menu%,adjust%,i%,j%,xsize%,ysize%,up%,lo%
  1892. select%=(button%=4)
  1893. menu%=(button%=2)
  1894. adjust%=(button%=1)
  1895.  window% 
  1896.  select% 
  1897.       
  1898. redefinebrowser(
  1899.        
  1900. openwindow(TemplW%,3)
  1901. 4      
  1902.  IcInfo_Active% 
  1903. openwindow(IcInfoW%,4)
  1904.         
  1905.  IcEdW%
  1906. 6    
  1907. iced_click(xpos%,ypos%,select%,adjust%,icon%)
  1908.  WinEdW%
  1909. 7    
  1910. wined_click(xpos%,ypos%,select%,adjust%,icon%)
  1911.  StatW%
  1912. !    
  1913.  (icon%=1) 
  1914.  (icon%=2) 
  1915. "      Stats_Decimal%=(icon%=1)
  1916. %      
  1917. selecticon(StatW%,icon%,1)
  1918.       
  1919. stat_fillwin
  1920.         
  1921.  TemplW%
  1922. ,    
  1923.  (select% 
  1924.  adjust%) 
  1925.  (icon%>=0) 
  1926. ,      ScrapBlk%!0=TemplHandle%!(4*icon%)
  1927. -      
  1928.  "Wimp_GetWindowState",,ScrapBlk%
  1929. $      
  1930.  ScrapBlk%!32 
  1931.  (1<<16) 
  1932. !        
  1933. closetemplate(icon%)
  1934.       
  1935.          
  1936. opentemplate(icon%)
  1937.       
  1938. &      
  1939. selecticon(TemplW%,icon%,0)
  1940.         
  1941.      
  1942.  select% 
  1943.  (icon%=-1) 
  1944.        
  1945. sel_clear(TemplW%,-1)
  1946.         
  1947. '    
  1948.  (button%=16) 
  1949.  (button%=64) 
  1950. !      
  1951. dragselect(button%>>4)
  1952.         
  1953.  SaveW%
  1954.  icon% 
  1955.       
  1956.         
  1957.  Exporting% 
  1958. ,          
  1959. exporttemplates($(FileName%))
  1960.         
  1961. "          
  1962.  SavingSelection% 
  1963. &            SelFname$=$(FileName%)
  1964. )            
  1965. savetemplates(SelFname$)
  1966.           
  1967. +            
  1968. setmainfname($(FileName%))
  1969. *            
  1970. savetemplates(MainFname$)
  1971.           
  1972.         
  1973. $        
  1974.  "Wimp_CreateMenu",,-1
  1975.       
  1976.          
  1977.  (button%>>4) 
  1978. $          
  1979. startsavedrag(SaveW%)
  1980.         
  1981.         
  1982.  ExportW%
  1983.  icon% 
  1984.       
  1985. -        
  1986. export_savenames($(ExportName%))
  1987.       
  1988.          
  1989.  (button%>>4) 
  1990. &          
  1991. startsavedrag(ExportW%)
  1992.         
  1993.       
  1994.  3,4,5
  1995. $        
  1996. export_settype(icon%-3)
  1997.         
  1998.  AlignW%
  1999.  icon% 
  2000.       
  2001. &        
  2002. alignicons(LastMenu_Win%)
  2003. 4        
  2004.  adjust%) 
  2005.  "Wimp_CreateMenu",,-1
  2006.       
  2007.         
  2008. align_shadeicons
  2009.         
  2010.  SpaceW%
  2011.  icon% 
  2012.       
  2013. /        SpaceOut_Space%=
  2014. ($(IconText%(18)))
  2015. %        up%=(adjust% 
  2016.  (icon%=7))
  2017. :        
  2018. changevar(SpaceOut_Space%,4,up%,-512,512) 
  2019. 1          
  2020. seticontext(18,
  2021. (SpaceOut_Space%))
  2022. "          
  2023. setcaret(SpaceW%,6)
  2024.         
  2025.      
  2026.         
  2027. space_shadeicons
  2028. (        
  2029.  icon%=8 
  2030. setcaret(-1,-1)
  2031.       
  2032. &        
  2033. spaceicons(LastMenu_Win%)
  2034. 4        
  2035.  adjust%) 
  2036.  "Wimp_CreateMenu",,-1
  2037.         
  2038.  FrameW%
  2039.  icon% 
  2040.       
  2041. -        Frame_IconNo%=
  2042. ($(IconText%(32)))
  2043. %        up%=(adjust% 
  2044.  (icon%=9))
  2045. 5        
  2046. changevar(Frame_IconNo%,1,up%,0,512) 
  2047. /          
  2048. seticontext(32,
  2049. (Frame_IconNo%))
  2050. "          
  2051. setcaret(FrameW%,7)
  2052.         
  2053.       
  2054.  12,13
  2055. ,        Frame_Space%=
  2056. ($(IconText%(33)))
  2057. &        up%=(adjust% 
  2058.  (icon%=13))
  2059. 4        
  2060. changevar(Frame_Space%,4,up%,0,512) 
  2061. .          
  2062. seticontext(33,
  2063. (Frame_Space%))
  2064. #          
  2065. setcaret(FrameW%,11)
  2066.         
  2067.       
  2068.  18,19
  2069. .        Frame_LabelNo%=
  2070. ($(IconText%(34)))
  2071. &        up%=(adjust% 
  2072.  (icon%=17))
  2073. 6        
  2074. changevar(Frame_LabelNo%,1,up%,0,512) 
  2075. 0          
  2076. seticontext(34,
  2077. (Frame_LabelNo%))
  2078. #          
  2079. setcaret(FrameW%,17)
  2080.         
  2081.       
  2082.  23,24
  2083. 0        Frame_LeftSpace%=
  2084. ($(IconText%(35)))
  2085. &        up%=(adjust% 
  2086.  (icon%=24))
  2087.     8        
  2088. changevar(Frame_LeftSpace%,4,up%,0,512) 
  2089. 2          
  2090. seticontext(35,
  2091. (Frame_LeftSpace%))
  2092. #          
  2093. setcaret(FrameW%,22)
  2094.         
  2095.       
  2096. 4        
  2097.  adjust%) 
  2098.  "Wimp_CreateMenu",,-1
  2099. &        
  2100. frameicons(LastMenu_Win%)
  2101.       
  2102.  5,6,15,16,20,21
  2103. 4        
  2104.  adjust% 
  2105. selecticon(FrameW%,icon%,1)
  2106.         
  2107. frame_shadeicons
  2108.         
  2109.  WorkW%
  2110.  icon%<=26 
  2111. +      
  2112.  (icon%>=9) 
  2113.  ((icon% 
  2114.  3)<>1) 
  2115. "        
  2116.  click on arrow icons
  2117. )        up%=((icon% 
  2118.  3)=2) 
  2119.  adjust%
  2120.         i%=(icon%-9) 
  2121. %        j%=
  2122. ($(IconText%(12+i%)))
  2123.         
  2124.  i%<2 
  2125.           lo%=-10000
  2126.         
  2127. 7          lo%=0 : 
  2128.  "size" field, can't be negative
  2129.         
  2130.  .        
  2131. changevar(j%,4,up%,lo%,10000) 
  2132. !'          
  2133. seticontext(12+i%,
  2134. (j%))
  2135. "'          
  2136. setcaret(WorkW%,3*i%+10)
  2137.         
  2138.       
  2139.                  
  2140. &!      WinBlk%!0=LastMenu_Win%
  2141. '+      
  2142.  "Wimp_GetWindowState",,WinBlk%
  2143.       
  2144.  icon% 
  2145.         
  2146.  27,28
  2147. *?          xsize%=WinBlk%!12-WinBlk%!4+WinBlk%!20-WinBlk%!44
  2148. +?          ysize%=WinBlk%!16-WinBlk%!8-WinBlk%!24+WinBlk%!56
  2149.           
  2150.  icon%=27 
  2151. -.            
  2152. seticontext(12,
  2153. (WinBlk%!44))
  2154. ..            
  2155. seticontext(13,
  2156. (WinBlk%!56))
  2157. /*            
  2158. seticontext(14,
  2159. (xsize%))
  2160. 0*            
  2161. seticontext(15,
  2162. (ysize%))
  2163. 1$            
  2164. setcaret(WorkW%,16)
  2165.           
  2166. 3*            
  2167. seticontext(16,
  2168. (xsize%))
  2169. 4*            
  2170. seticontext(17,
  2171. (ysize%))
  2172. 5$            
  2173. setcaret(WorkW%,22)
  2174.           
  2175.         
  2176. 8"          
  2177. seticontext(12,"0")
  2178. 9"          
  2179. seticontext(13,"0")
  2180. :%          
  2181. seticontext(14,"1236")
  2182. ;$          
  2183. seticontext(15,"936")
  2184. <"          
  2185. seticontext(16,"0")
  2186. ="          
  2187. seticontext(17,"0")
  2188. >"          
  2189. setcaret(WorkW%,16)
  2190.         
  2191.           
  2192. setworkarea
  2193. A6          
  2194.  adjust%) 
  2195.  "Wimp_CreateMenu",,-1
  2196.         
  2197.       
  2198. D        
  2199.  OptPaneW%
  2200.  icon% 
  2201. G*      
  2202.  8  : TrapDclick%=
  2203.  TrapDclick%
  2204.       
  2205. I.        
  2206. iconselected(OptPaneW%,icon%) 
  2207.           
  2208. support(1)
  2209.         
  2210.           
  2211. support(0)
  2212.         
  2213.       
  2214. O.        
  2215. iconselected(OptPaneW%,icon%) 
  2216.           
  2217. support(2)
  2218.         
  2219.           
  2220. support(0)
  2221.         
  2222.       
  2223. U.        
  2224. iconselected(OptPaneW%,icon%) 
  2225.           
  2226. support(3)
  2227.         
  2228.           
  2229. support(0)
  2230.         
  2231.       
  2232. [.        
  2233. iconselected(OptPaneW%,icon%) 
  2234.           
  2235. support(4)
  2236.         
  2237.           
  2238. support(0)
  2239.         
  2240. `(      
  2241.  11 : DuplNames%=
  2242.  DuplNames%
  2243.       
  2244.         Hatch%=
  2245.  Hatch%
  2246.         
  2247. redrawall
  2248.       
  2249. e+        IcInfo_Active%=
  2250.  IcInfo_Active%
  2251.         
  2252.  IcInfo_Active% 
  2253. g%          
  2254. openwindow(IcInfoW%,4)
  2255.         
  2256. i$          
  2257. closewindow(IcInfoW%)
  2258.         
  2259. k4      
  2260.  14 : Save_Unselected%=
  2261.  Save_Unselected%
  2262. l0      
  2263.  15 : DeleteOutside%=
  2264.  DeleteOutside%
  2265. m2      
  2266.  35 : IgnoreDeskFont%=
  2267.  IgnoreDeskFont%
  2268. n0      
  2269.  16 : Grid_SizeLock%=
  2270.  Grid_SizeLock%
  2271.       
  2272.  18,20
  2273. p&        up%=(adjust% 
  2274.  (icon%=20))
  2275. qD        
  2276. changevar(Grid_SizeX%,PixToOS_X%,up%,PixToOS_X%,64) 
  2277. r-          
  2278. seticontext(28,
  2279. (Grid_SizeX%))
  2280.         
  2281.       
  2282.  22,24
  2283. u&        up%=(adjust% 
  2284.  (icon%=24))
  2285. vD        
  2286. changevar(Grid_SizeY%,PixToOS_Y%,up%,PixToOS_Y%,64) 
  2287. w-          
  2288. seticontext(29,
  2289. (Grid_SizeY%))
  2290.         
  2291. y.      
  2292.  25 : Grid_PosLock%=
  2293.  Grid_PosLock%
  2294.       
  2295.  27,29
  2296. {&        up%=(adjust% 
  2297.  (icon%=29))
  2298. |C        
  2299. changevar(Grid_PosX%,PixToOS_X%,up%,PixToOS_X%,64) 
  2300. },          
  2301. seticontext(30,
  2302. (Grid_PosX%))
  2303.         
  2304.       
  2305.  31,33
  2306. &        up%=(adjust% 
  2307.  (icon%=33))
  2308. C        
  2309. changevar(Grid_PosY%,PixToOS_Y%,up%,PixToOS_Y%,64) 
  2310. ,          
  2311. seticontext(31,
  2312. (Grid_PosY%))
  2313.         
  2314.         
  2315.  OptionsW%
  2316.  icon% 
  2317.       
  2318.         
  2319. setup_save
  2320. #        
  2321. closewindow(OptionsW%)
  2322.       
  2323. #        
  2324. closewindow(OptionsW%)
  2325.         
  2326.  DialW%
  2327.      
  2328.  "Wimp_CreateMenu",,-1
  2329.  LastDialogue% 
  2330.       
  2331. ,        
  2332.  program quit with changes made
  2333.         
  2334.  icon% 
  2335.           
  2336. 2            
  2337.  "Wimp_GetPointerInfo",,PtrInfo%
  2338. '            $(FileName%)=MainFname$
  2339. )            $SaveFileIcon%="file_fec"
  2340. "            SavingSelection%=
  2341.             Exporting%=
  2342.              QuitAfterSave%=
  2343. 1            
  2344. createwinmenu(-1,SaveW%,-126,56)
  2345.           
  2346.             
  2347. prequit
  2348.         
  2349.       
  2350. *        
  2351.  delete all with changes made
  2352. (        
  2353.  icon%=1 
  2354. templ_deleteall
  2355.       
  2356. -        
  2357.  load new file with changes made
  2358.         
  2359.  icon%=1 
  2360.           
  2361. templ_deleteall
  2362. *          
  2363. templ_loadfile(NewFname$,1)
  2364. &          
  2365. setmainfname(NewFname$)
  2366.         
  2367.       
  2368. 1        
  2369.  exit from desktop with changes made
  2370.         
  2371.  icon% 
  2372.           
  2373.              
  2374. templ_deleteall
  2375. A            
  2376.  resume prequit procedure (code copied from PRM)
  2377. 5            
  2378.  "Wimp_GetCaretPosition",,ScrapBlk%
  2379. !            ScrapBlk%!24=&1FC
  2380. @            
  2381.  "Wimp_SendMessage",8,ScrapBlk%,PreQuitSender%
  2382.         
  2383.         
  2384. wined_click(xpos%,ypos%,select%,adjust%,icon%)
  2385.  up%,i%,gcol%
  2386.  icon% 
  2387. wined_readwin
  2388. wined_readwin
  2389. closewindow(WinEdW%)
  2390.      
  2391. setcaret(WinEd_Win%,-1)
  2392. closewindow(WinEdW%)
  2393.      
  2394. setcaret(WinEd_Win%,-1)
  2395. '    
  2396. iconselected(WinEdW%,20) 
  2397. ;      
  2398. selecticon(WinEdW%,14,
  2399. iconselected(WinEdW%,13))
  2400.         
  2401. '    
  2402. iconselected(WinEdW%,20) 
  2403. ;      
  2404. selecticon(WinEdW%,13,
  2405. iconselected(WinEdW%,14))
  2406.         
  2407.  15,17,19,20
  2408.      
  2409. wined_shadeicons(icon%)
  2410.  23,27,31,35,39,43,47,51
  2411. .    
  2412. createmenu(xpos%,ypos%,WinEdW%,icon%)
  2413.  22,24
  2414. "    up%=(adjust% 
  2415.  (icon%=24))
  2416. 0    
  2417. changevar(WinEd_Button%,1,up%,0,15) 
  2418. 8      
  2419. seticontext(6,$(WinButton%+20*WinEd_Button%))
  2420.         
  2421.     WinEd_Col%(0)=7
  2422.     WinEd_Col%(1)=2
  2423.     WinEd_Col%(2)=7
  2424.     WinEd_Col%(3)=1
  2425.     WinEd_Col%(4)=3
  2426.     WinEd_Col%(5)=1
  2427.     WinEd_Col%(6)=12
  2428.  i%=0 
  2429. ,      
  2430. setcolourbox(2+i%,WinEd_Col%(i%))
  2431. 7    
  2432.  (icon%>=26) 
  2433.  (icon%<=52) 
  2434.  ((icon% 
  2435.  2)=0) 
  2436. '      up%=((icon% 
  2437.  4)=0) 
  2438.  adjust%
  2439.       i%=(icon%-26) 
  2440. (      gcol%=
  2441. iconselected(WinEdW%,9)
  2442. ;      
  2443. changecolourbox(2+i%,WinEd_Col%(i%),1,up%,gcol%)
  2444.         
  2445. iced_click(xpos%,ypos%,select%,adjust%,icon%)
  2446.  up%,l%
  2447.  icon% 
  2448. .    
  2449.  adjust% 
  2450. iconselected(IcEdW%,14) 
  2451. /      
  2452.  minimize number in 'Max size' field
  2453. &      
  2454. iconselected(IcEdW%,12) 
  2455. #          l%=
  2456. ($(IconText%(0)))
  2457.       
  2458. (        
  2459. iconselected(IcEdW%,13) 
  2460. #          l%=
  2461. ($(IconText%(1)))
  2462.         
  2463.       
  2464. !      
  2465. seticontext(3,
  2466. (l%+1))
  2467.         
  2468. iced_readwin(-1)
  2469. iced_readwin(-1)
  2470. closewindow(IcEdW%)
  2471. setcaret(IcEd_Win%,-1)
  2472. closewindow(IcEdW%)
  2473. setcaret(IcEd_Win%,-1)
  2474.  12,13,14,41,53
  2475. iced_shadeicons(icon%)
  2476.  28,31,34,37,45,46,48,51
  2477. -    
  2478. createmenu(xpos%,ypos%,IcEdW%,icon%)
  2479.  27,29
  2480. "    up%=(adjust% 
  2481.  (icon%=29))
  2482. /    
  2483. changevar(IcEd_Button%,1,up%,0,15) 
  2484. 6      
  2485. seticontext(4,$(IcButton%+20*IcEd_Button%))
  2486.         
  2487.  30,32
  2488. "    up%=(adjust% 
  2489.  (icon%=32))
  2490. ,    
  2491. changevar(IcEd_Esg%,1,up%,0,31) 
  2492. &      
  2493. seticontext(5,
  2494. (IcEd_Esg%))
  2495.         
  2496.  33,35
  2497. "    up%=(adjust% 
  2498.  (icon%=35))
  2499. /    
  2500. changecolourbox(0,IcEd_Fgcol%,1,up%,0)
  2501.  36,38
  2502. "    up%=(adjust% 
  2503.  (icon%=38))
  2504. /    
  2505. changecolourbox(1,IcEd_Bgcol%,1,up%,0)
  2506.  47,49
  2507. ;    
  2508.  (adjust% 
  2509.  (icon%=47)) 
  2510.  (select% 
  2511.  (icon%=49)) 
  2512.       
  2513.  IcEd_Xsize<998 
  2514.         IcEd_Xsize+=2
  2515. .        
  2516. seticontext(20,
  2517. (IcEd_Xsize),4))
  2518. (        
  2519. iconselected(IcEdW%,53) 
  2520. #          IcEd_Ysize=IcEd_Xsize
  2521. 0          
  2522. seticontext(21,
  2523. (IcEd_Ysize),4))
  2524.         
  2525.       
  2526.         
  2527.       
  2528.  IcEd_Xsize>2 
  2529.         IcEd_Xsize-=2
  2530. !.        
  2531. seticontext(20,
  2532. (IcEd_Xsize),4))
  2533. "(        
  2534. iconselected(IcEdW%,53) 
  2535. ##          IcEd_Ysize=IcEd_Xsize
  2536. $0          
  2537. seticontext(21,
  2538. (IcEd_Ysize),4))
  2539.         
  2540.       
  2541. '        
  2542.  50,52
  2543. );    
  2544.  (adjust% 
  2545.  (icon%=50)) 
  2546.  (select% 
  2547.  (icon%=52)) 
  2548.       
  2549.  IcEd_Ysize<998 
  2550.         IcEd_Ysize+=2
  2551. ,.        
  2552. seticontext(21,
  2553. (IcEd_Ysize),4))
  2554.       
  2555. .        
  2556.       
  2557.  IcEd_Ysize>2 
  2558.         IcEd_Ysize-=2
  2559. 1.        
  2560. seticontext(21,
  2561. (IcEd_Ysize),4))
  2562.       
  2563. 3        
  2564. receive(buf%)
  2565.  sender%,ref%,code%,ackcode%,acktype%,fname$,ftype%,icon%,no%,boot$
  2566.  selinfo%,item%
  2567. sender%=buf%!4
  2568. ref%=buf%!8
  2569. code%=buf%!16
  2570. =Cackcode%=0 : 
  2571.  sort of message to acknowledge this message with
  2572. >/acktype%=17 : 
  2573.  message type of acknowledge
  2574.  sender% <> ThisTask% 
  2575.  code% 
  2576.       
  2577.  'quit' message
  2578.       
  2579. prequit
  2580.       
  2581.  data save
  2582.       
  2583.  buf%!40=&FEC 
  2584. G>        
  2585.  other app saves file to TemplEd (via Wimp$Scrap)
  2586. H&        NewLeafName$=
  2587. str(buf%+44)
  2588. I%        $(buf%+44)="<Wimp$Scrap>"
  2589. J1        buf%!36=-1 : 
  2590.  saved file is "unsafe"
  2591.         ackcode%=2
  2592.       
  2593.       
  2594.  data save ack
  2595.       fname$=
  2596. str(buf%+44)
  2597.       
  2598.  Drag_Win% 
  2599.         
  2600.  SaveW%
  2601.           
  2602.  Exporting% 
  2603. S(            
  2604. exporttemplates(fname$)
  2605.           
  2606. U$            
  2607.  SavingSelection% 
  2608. V"              SelFname$=fname$
  2609. W+              
  2610. savetemplates(SelFname$)
  2611.             
  2612. Y>              
  2613.  (buf%!36<>-1) 
  2614.  (fname$<>"<Wimp$Scrap>") 
  2615. Z)                
  2616. setmainfname(fname$)
  2617.               
  2618. \(              
  2619. savetemplates(fname$)
  2620.             
  2621.           
  2622.         
  2623.  ExportW%
  2624. `'          
  2625. export_savenames(fname$)
  2626.       
  2627. b3      
  2628.  "OS_File",17,fname$ 
  2629.  ftype%,,,,fsize%
  2630.       
  2631.  ftype%=1 
  2632.         ackcode%=3
  2633.         buf%!36=fsize%
  2634.       
  2635. g"      
  2636.  "Wimp_CreateMenu",,-1
  2637.       
  2638.  data load
  2639. j!      NewFname$=
  2640. str(buf%+44)
  2641.       
  2642.  buf%!40 
  2643.         
  2644.  &FEC
  2645.           
  2646.  buf%!20 
  2647.             
  2648.  TemplW%
  2649. o-              
  2650. setchanged(NrTemplates%>0)
  2651. p.              
  2652. templ_loadfile(NewFname$,0)
  2653.               ackcode%=4
  2654.             
  2655. s&              
  2656.  buf%!24=BarIcon% 
  2657. t$                
  2658.  ChangesMade% 
  2659. u%                  
  2660. dialogue(2,"")
  2661.                 
  2662. w&                  
  2663. templ_deleteall
  2664. x2                  
  2665. templ_loadfile(NewFname$,1)
  2666.                 
  2667.               
  2668.               ackcode%=4
  2669.           
  2670.         
  2671.  &FF9
  2672. ~3          
  2673.  (buf%!20=-2) 
  2674.  (buf%!24=BarIcon%) 
  2675. +            
  2676. loadusersprites(NewFname$)
  2677.             ackcode%=4
  2678.           
  2679.         
  2680.  &2000
  2681. 2          NewFname$=
  2682. str(buf%+44)+".Templates"
  2683. H          
  2684. fileexists(NewFname$)
  2685. (buf%!20=-2)
  2686. (buf%!24=BarIcon%) 
  2687.              
  2688.  ChangesMade% 
  2689. !              
  2690. dialogue(2,"")
  2691.             
  2692. "              
  2693. templ_deleteall
  2694. .              
  2695. templ_loadfile(NewFname$,1)
  2696.             
  2697.             ackcode%=4
  2698.           
  2699.       
  2700. "      
  2701.  double-click on a file
  2702. !      NewFname$=
  2703. str(buf%+44)
  2704.       
  2705.  buf%!40 
  2706.         
  2707.  &FEC
  2708.            
  2709.  NrTemplates%=0 
  2710. ,            
  2711. templ_loadfile(NewFname$,1)
  2712.             ackcode%=4
  2713.           
  2714.       
  2715.       
  2716.  desktop exit
  2717.       
  2718.  ChangesMade% 
  2719.         ackcode%=8
  2720.         acktype%=19
  2721. "        PreQuitSender%=sender%
  2722.         
  2723. dialogue(8,"")
  2724.       
  2725. #      
  2726.  desktop save (RiscOS 3)
  2727. 5      boot$="Run "+
  2728. readvarval("TemplEd$Dir")+
  2729. /      
  2730.  "OS_GBPB",2,buf%!20,boot$,
  2731. (boot$)
  2732.  &502
  2733. *      
  2734.  request from !Help application
  2735. %      no%=
  2736. whichtemplate(buf%!32)
  2737.       icon%=buf%!36
  2738. $      
  2739.  (no%>=0) 
  2740.  (icon%>=-1) 
  2741. +        $(buf%+20)=
  2742. iconhelp(no%,icon%)
  2743.         ackcode%=&503
  2744.       
  2745.  &400C0
  2746. !      
  2747.  about to open submenu
  2748. =      
  2749.  "MenuUtil_Decode",LastMenu%,buf%+32 
  2750.  ,,selinfo%
  2751.       item%=selinfo%!8
  2752.       
  2753.  item% 
  2754.         
  2755.  item_createtempl%
  2756. '          
  2757.  template name to create
  2758. 3          
  2759.  "MenuUtil_Text",item_templname%,""
  2760. /        
  2761.  item_copytempl%,item_renametempl%
  2762.           
  2763. sel_get(TemplW%)
  2764. /          
  2765.  template name to copy or rename
  2766. N          
  2767.  "MenuUtil_Text",item_templname%,$(TemplNames%+28*(SelBlk%!0))
  2768.         
  2769.  item_exporttempl%
  2770. '          $(FileName%)=ExportTname$
  2771.            SavingSelection%=
  2772.           Exporting%=
  2773. '          $SaveFileIcon%="file_fff"
  2774.         
  2775.  item_exportnames%
  2776.           
  2777.  ExportType% 
  2778.             
  2779. 6              $(ExportName%)=
  2780. locase(ExportIname$)
  2781.             
  2782. -              $(ExportName%)=ExportIname$
  2783.           
  2784.         
  2785.  item_frame%
  2786.           
  2787. frame_fillwin
  2788.         
  2789.  item_save%
  2790. +          
  2791.  set filename in save window
  2792. %          $(FileName%)=MainFname$
  2793.            SavingSelection%=
  2794.           Exporting%=
  2795. '          $SaveFileIcon%="file_fec"
  2796.         
  2797.  item_savetempl%
  2798. 0          
  2799.  set template name in save window
  2800. $          $(FileName%)=SelFname$
  2801.            SavingSelection%=
  2802.           Exporting%=
  2803. '          $SaveFileIcon%="file_fec"
  2804.         
  2805.  item_workarea%
  2806. -          
  2807.  fill icons in workarea window
  2808. %          WinBlk%!0=LastMenu_Win%
  2809. .          
  2810.  "Wimp_GetWindowInfo",,WinBlk%
  2811. ,          $(IconText%(12))=
  2812. (WinBlk%!44)
  2813. ,          $(IconText%(13))=
  2814. (WinBlk%!56)
  2815. 7          $(IconText%(14))=
  2816. (WinBlk%!52-WinBlk%!44)
  2817. 7          $(IconText%(15))=
  2818. (WinBlk%!56-WinBlk%!48)
  2819. 6          $(IconText%(16))=
  2820. ((WinBlk%!72) 
  2821.  &FFFF)
  2822. 2          $(IconText%(17))=
  2823. ((WinBlk%!72)>>16)
  2824.       
  2825. :      
  2826.  "Wimp_CreateSubMenu",,buf%!20,buf%!24,buf%!28
  2827.  &400C1
  2828.       
  2829.  mode change
  2830.       
  2831. readscreenvars
  2832. =      
  2833.  TemplW_MaxCol%<TemplW_Cols% 
  2834. redefinebrowser(
  2835.  &400C9
  2836. 1      
  2837.  menu removed with no menu item chosen
  2838. "      
  2839.  LastMenu%=TemplMenu% 
  2840. :        
  2841.  TemplMenu_Deselect% 
  2842. sel_clear(TemplW%,-1)
  2843.       
  2844.  &80E1E
  2845. 4      
  2846.  OLE file (user sprites) changed - reload
  2847. (      
  2848. loadusersprites(SpriteFname$)
  2849.  ackcode%<>0 
  2850.     buf%!0=256
  2851.     buf%!12=ref%
  2852.     buf%!16=ackcode%
  2853. -    
  2854.  "Wimp_SendMessage",17,buf%,sender%
  2855. redraw(handle%)
  2856.  more%,win0x%,win0y%,dx%
  2857.  xstart%,height%,xcorr%,ycorr%,x%,y%
  2858. dx%=48
  2859. Blk%!0=handle%
  2860.  "Wimp_RedrawWindow",,Blk% 
  2861.  more%
  2862. win0x%=Blk%!4-Blk%!20
  2863. win0y%=Blk%!16-Blk%!24
  2864.  more%
  2865.  Hatch% 
  2866.     height%=Blk%!40-Blk%!32
  2867.     xstart%=Blk%!28-height%
  2868. %    xcorr%=(xstart%-win0x%) 
  2869. %    ycorr%=(win0y%-Blk%!32) 
  2870. 4    
  2871.  x%=xstart%-(xcorr%+ycorr%) 
  2872.  Blk%!36 
  2873.       
  2874.  x%,Blk%!32
  2875.       
  2876.  1,height%,height%
  2877. %    ycorr%=(win0y%-Blk%!40) 
  2878. 4    
  2879.  x%=xstart%-(xcorr%-ycorr%) 
  2880.  Blk%!36 
  2881.       
  2882.  x%,Blk%!40
  2883.       
  2884.  1,height%,-height%
  2885.  Support% 
  2886. &      
  2887.  "Wimp_BorderWindow",,Blk%
  2888. %      
  2889.  "AEH_RedrawWindow",,Blk%
  2890. #      
  2891.  "WimpExt_Redraw",,Blk%
  2892. 3      
  2893.  "Sculptrix_SetSpriteArea",UserSprites%
  2894. +      
  2895.  "Sculptrix_RedrawWindow",,Blk%
  2896.  "Wimp_GetRectangle",,Blk% 
  2897.  more%
  2898.  *** procs for the window-edit window ***
  2899. wined_fillwin(window%)
  2900.  no%,flags%,i%
  2901. whichtemplate(window%)
  2902. WinEd_Win%=window%
  2903. WinBlk%!0=WinEd_Win%
  2904.  "Wimp_GetWindowInfo",,WinBlk%
  2905. flags%=WinBlk%!32
  2906. $"WinEd_Button%=(WinBlk%!64)>>12
  2907.  i%=0 
  2908. &&  WinEd_Col%(i%)=(WinBlk%?(36+i%))
  2909. selecticon(WinEdW%,4,flags% 
  2910.  (1<<1))
  2911. selecticon(WinEdW%,5,flags% 
  2912.  (1<<4))
  2913. selecticon(WinEdW%,6,flags% 
  2914.  (1<<12))
  2915. selecticon(WinEdW%,7,PaneFlag%?no%)
  2916. selecticon(WinEdW%,8,flags% 
  2917.  (1<<6))
  2918. selecticon(WinEdW%,9,flags% 
  2919.  (1<<10))
  2920. selecticon(WinEdW%,10,flags% 
  2921.  (1<<11))
  2922. selecticon(WinEdW%,20,flags% 
  2923.  (1<<31))
  2924. selecticon(WinEdW%,57,flags% 
  2925.  (1<<13))
  2926. selecticon(WinEdW%,59,flags% 
  2927.  (1<<8))
  2928. selecticon(WinEdW%,60,flags% 
  2929.  (1<<9))
  2930. selecticon(WinEdW%,62,flags% 
  2931.  (1<<14))
  2932. selecticon(WinEdW%,63,flags% 
  2933.  (1<<15))
  2934.  i%=0 
  2935. selecticon(WinEdW%,13+i%,flags% 
  2936.  (1<<(24+i%)))
  2937.  (flags% 
  2938.  (1<<31))=0 
  2939. selecticon(WinEdW%,14,(flags% 
  2940.  (1<<7))=0)
  2941. selecticon(WinEdW%,13,(flags% 
  2942.  (1<<7))=0)
  2943. selecticon(WinEdW%,15,flags% 
  2944.  (1<<0))
  2945. selecticon(WinEdW%,17,flags% 
  2946.  (1<<2))
  2947. selecticon(WinEdW%,19,flags% 
  2948.  (1<<3))
  2949. settitlebar(WinEdW%,WinEdTbar%,
  2950. msg_lookup1("EDTP",$(TemplNames%+28*no%)))
  2951. seticontext(6,$(WinButton%+20*WinEd_Button%))
  2952.  i%=0 
  2953. setcolourbox(2+i%,WinEd_Col%(i%))
  2954. wined_shadeicons(-1)
  2955. openwindow(WinEdW%,0)
  2956. setcaret(WinEdW%,-1)
  2957. wined_shadeicons(clickedon%)
  2958.  newformat%,titlebar%,scroll%
  2959. K(newformat%=
  2960. iconselected(WinEdW%,20)
  2961. L'titlebar%=
  2962. iconselected(WinEdW%,15)
  2963. MAscroll%=
  2964. iconselected(WinEdW%,17) 
  2965. iconselected(WinEdW%,19)
  2966.  (clickedon%=-1) 
  2967.  (clickedon%=20) 
  2968. shadeicon(WinEdW%,16,
  2969.  newformat%)
  2970.  (clickedon%=-1) 
  2971.  (clickedon%=15) 
  2972. shadeicon(WinEdW%,13,
  2973.  titlebar%)
  2974. shadeicon(WinEdW%,14,
  2975.  titlebar%)
  2976. shadeicon(WinEdW%,16,
  2977.  titlebar%)
  2978.  (clickedon%<>15) 
  2979. shadeicon(WinEdW%,18,newformat% 
  2980.  scroll%))
  2981. wined_readwin
  2982.  flags%,no%,i%
  2983. WinBlk%!0=WinEd_Win%
  2984.  "Wimp_GetWindowInfo",,WinBlk%
  2985. _!flags%=(WinBlk%!32)
  2986. (&1F<<16)
  2987. iconselected(WinEdW%,15) 
  2988.  flags%+=(1<<0)
  2989. iconselected(WinEdW%,4) 
  2990.  flags%+=(1<<1)
  2991. iconselected(WinEdW%,17) 
  2992.  flags%+=(1<<2)
  2993. iconselected(WinEdW%,19) 
  2994.  flags%+=(1<<3)
  2995. iconselected(WinEdW%,5) 
  2996.  flags%+=(1<<4)
  2997. e"no%=
  2998. whichtemplate(WinEd_Win%)
  2999. iconselected(WinEdW%,7) 
  3000.   PaneFlag%?no%=1<<5
  3001.   PaneFlag%?no%=0
  3002. iconselected(WinEdW%,8) 
  3003.  flags%+=(1<<6)
  3004. iconselected(WinEdW%,14) 
  3005.  flags%+=(1<<7)
  3006. iconselected(WinEdW%,59) 
  3007.  flags%+=(1<<8)
  3008. iconselected(WinEdW%,60) 
  3009.  flags%+=(1<<9)
  3010. iconselected(WinEdW%,9) 
  3011.  flags%+=(1<<10)
  3012. iconselected(WinEdW%,10) 
  3013.  flags%+=(1<<11)
  3014. iconselected(WinEdW%,6) 
  3015.  flags%+=(1<<12)
  3016. iconselected(WinEdW%,57) 
  3017.  flags%+=(1<<13)
  3018. iconselected(WinEdW%,62) 
  3019.  flags%+=(1<<14)
  3020. iconselected(WinEdW%,63) 
  3021.  flags%+=(1<<15)
  3022.  i%=0 
  3023. iconselected(WinEdW%,13+i%) 
  3024.  flags%+=(1<<(24+i%))
  3025. WinBlk%!32=flags%
  3026. y WinBlk%!64=WinEd_Button%<<12
  3027.  i%=0 
  3028. {$  WinBlk%?(36+i%)=WinEd_Col%(i%)
  3029. })WinEd_Win%=
  3030. redefinewindow(WinBlk%,1)
  3031.  *** procs for the icon-edit window ***
  3032. iced_start(window%,icon%)
  3033.  icon%=-4 
  3034. iced_fillwin(window%,-4)
  3035. sel_get(window%)
  3036.  NrSelected%>0 
  3037.      
  3038.  NrSelected%=1 
  3039. *      
  3040. iced_fillwin(window%,SelBlk%!0)
  3041.      
  3042. $       
  3043. iced_fillwin(window%,-1)
  3044.      
  3045.  (icon%>=0) 
  3046. &      
  3047. iced_fillwin(window%,icon%)
  3048.         
  3049. iced_fillwin(window%,icon%)
  3050.  no%,flags%,data%,arg$,title$,text%,sprite%,indir%,caretto%
  3051.  t$,v$,m$,s$
  3052. IcEd_Win%=window%
  3053. IcEd_Icon%=icon%
  3054. whichtemplate(window%)
  3055. WinBlk%!0=IcEd_Win%
  3056.  "Wimp_GetWindowInfo",,WinBlk%
  3057.  icon% 
  3058.  -4  : 
  3059.  editing title bar icon
  3060. D    flags%=(WinBlk%!60) 
  3061.  &FF000FFF : 
  3062.  mask out irrelevant bits
  3063.     flags%=flags% 
  3064.  (flags% 
  3065.  (1<<6))=0 
  3066. ;      
  3067.  copy fg and bg colour flags from window colours
  3068. J      flags%=(flags% 
  3069.  &FFF) 
  3070.  ((WinBlk%?36)<<24) 
  3071.  ((WinBlk%?37)<<28)
  3072.         
  3073.     data%=WinBlk%+76
  3074. "    arg$+=
  3075. msg_lookup0("TBAR")
  3076.  -1  : 
  3077.  editing selection (read flags from first icon)
  3078. sel_get(IcEd_Win%)
  3079. -    flags%=WinBlk%!(92+32*(SelBlk%!0)+16)
  3080. *    data%=WinBlk%+92+32*(SelBlk%!0)+20
  3081. !    arg$+=
  3082. msg_lookup0("SEL")
  3083.  editing single icon
  3084. ,    flags%=WinBlk%!(92+32*IcEd_Icon%+16)
  3085. )    data%=WinBlk%+92+32*IcEd_Icon%+20
  3086. +    arg$+=
  3087. msg_lookup1("ICNR",
  3088. (icon%))
  3089. :title$=
  3090. msg_lookup2("EDIC",$(TemplNames%+28*no%),arg$)
  3091. text%=(flags% 
  3092.  1)>0
  3093. sprite%=(flags% 
  3094.  2)>0
  3095. indir%=(flags% 
  3096.  &100)>0
  3097.  text% 
  3098.  indir% 
  3099.     t$=
  3100. str(data%!0)
  3101.     m$=
  3102. (data%!8)
  3103. (    
  3104.  data%!4<>-1 
  3105. str(data%!4)
  3106.     t$=
  3107. str(data%),12)
  3108.  sprite% 
  3109.  text%) 
  3110.  indir% 
  3111.     s$=
  3112. str(data%!0)
  3113.     m$=
  3114. (data%!8)
  3115.     s$=
  3116. str(data%),12)
  3117. "IcEd_Button%=(flags%>>12) 
  3118. IcEd_Esg%=(flags%>>16) 
  3119.  (flags% 
  3120.  (1<<6)) 
  3121.   IcEd_Fgcol%=7
  3122.   IcEd_Bgcol%=0
  3123. font_getinfo((flags%>>24) 
  3124.  255,IcEd_Font$,IcEd_Xsize,IcEd_Ysize)
  3125. #  IcEd_Fgcol%=(flags%>>24) 
  3126. #  IcEd_Bgcol%=(flags%>>28) 
  3127. "  IcEd_Font$="Homerton.Medium"
  3128.   IcEd_Xsize=12
  3129.   IcEd_Ysize=12
  3130. settitlebar(IcEdW%,IcEdTbar%,title$)
  3131. selecticon(IcEdW%,12,text%)
  3132. selecticon(IcEdW%,13,sprite%)
  3133. selecticon(IcEdW%,14,indir%)
  3134. seticontext(0,t$)
  3135. seticontext(1,s$)
  3136. seticontext(2,v$)
  3137. seticontext(3,m$)
  3138. selecticon(IcEdW%,15,flags% 
  3139.  (1<<2))
  3140. selecticon(IcEdW%,17,flags% 
  3141.  (1<<3))
  3142. selecticon(IcEdW%,18,flags% 
  3143.  (1<<4))
  3144. selecticon(IcEdW%,16,flags% 
  3145.  (1<<5))
  3146. selecticon(IcEdW%,41,flags% 
  3147.  (1<<6))
  3148. selecticon(IcEdW%,20,flags% 
  3149.  (1<<7))
  3150. selecticon(IcEdW%,19,flags% 
  3151.  (1<<9))
  3152. selecticon(IcEdW%,21,flags% 
  3153.  (1<<10))
  3154. selecticon(IcEdW%,22,flags% 
  3155.  (1<<11))
  3156. selecticon(IcEdW%,39,flags% 
  3157.  (1<<22))
  3158. seticontext(4,$(IcButton%+20*IcEd_Button%))
  3159. seticontext(5,
  3160. (IcEd_Esg%))
  3161. setcolourbox(0,IcEd_Fgcol%)
  3162. setcolourbox(1,IcEd_Bgcol%)
  3163. seticontext(19,IcEd_Font$)
  3164. seticontext(20,
  3165. (IcEd_Xsize),4))
  3166. seticontext(21,
  3167. (IcEd_Ysize),4))
  3168. selecticon(IcEdW%,53,IcEd_Xsize=IcEd_Ysize)
  3169.  i%=12 
  3170. shadeicon(IcEdW%,i%,IcEd_Icon%=-1)
  3171.  IcEd_Icon%=-1 
  3172.  i%=23 
  3173. shadeicon(IcEdW%,i%,1)
  3174. shadeicon(IcEdW%,15,IcEd_Icon%=-4)
  3175. shadeicon(IcEdW%,16,IcEd_Icon%=-4)
  3176. shadeicon(IcEdW%,20,IcEd_Icon%=-4)
  3177. shadeicon(IcEdW%,21,IcEd_Icon%=-4)
  3178.  i%=27 
  3179. shadeicon(IcEdW%,i%,IcEd_Icon%=-4)
  3180. shadeicon(IcEdW%,39,IcEd_Icon%=-4)
  3181. iced_shadeicons(-1)
  3182. openwindow(IcEdW%,0)
  3183. caretto%=-1
  3184.  IcEd_Icon%<>-1 
  3185.  indir% 
  3186.  caretto%=25
  3187.  sprite% 
  3188.  caretto%=24
  3189.  text% 
  3190.  caretto%=23
  3191. setcaret(IcEdW%,caretto%)
  3192. iced_shadeicons(clickedon%)
  3193.  t%,s%,i%,f%,lockaspect%
  3194.  IcEd_Icon%<>-1 
  3195.  (clickedon%=-1) 
  3196.  (clickedon%<=14) 
  3197. #    t%=
  3198. iconselected(IcEdW%,12)
  3199. #    s%=
  3200. iconselected(IcEdW%,13)
  3201. #    i%=
  3202. iconselected(IcEdW%,14)
  3203. "    
  3204. shadeicon(IcEdW%,23,
  3205. 0    
  3206. shadeicon(IcEdW%,24,(
  3207.  s%) 
  3208.  (t% 
  3209.  i%))
  3210. (    
  3211. shadeicon(IcEdW%,25,
  3212.  i%))
  3213. "    
  3214. shadeicon(IcEdW%,26,
  3215. iconselected(IcEdW%,41)
  3216. (lockaspect%=
  3217. iconselected(IcEdW%,53)
  3218.  (clickedon%=-1) 
  3219.  (clickedon%=41) 
  3220.  i%=33 
  3221.      
  3222. shadeicon(IcEdW%,i%,f%)
  3223.  i%=45 
  3224. "    
  3225. shadeicon(IcEdW%,i%,
  3226. shadeicon(IcEdW%,53,
  3227.  (clickedon%=-1) 
  3228.  (clickedon%=41) 
  3229.  (clickedon%=53) 
  3230.  i%=50 
  3231. "2    
  3232. shadeicon(IcEdW%,i%,(
  3233.  f%) 
  3234.  lockaspect%)
  3235.  "Wimp_GetCaretPosition",,ScrapBlk%
  3236. iconshaded(ScrapBlk%!0,ScrapBlk%!4) 
  3237. setcaret(IcEdW%,-1) : 
  3238.  move caret from shaded icon
  3239. iced_readwin(mask%)
  3240.  flags%,flagptr%,data%,ib%,cbp%,xsize,ysize
  3241.  xsize16%,ysize16%,fhandle%
  3242.  i%,t%,s%,deflen%,maxlen%,p%
  3243. WinBlk%!0=IcEd_Win%
  3244.  "Wimp_GetWindowInfo",,WinBlk%
  3245.  IcEd_Icon% 
  3246.  -4  : 
  3247.  editing title bar icon
  3248.     flagptr%=WinBlk%+60
  3249.     data%=WinBlk%+76
  3250.  -1  : 
  3251.  editing selection (read flags from first icon)
  3252. sel_get(IcEd_Win%)
  3253. 7-    flagptr%=WinBlk%+92+32*(SelBlk%!0)+16
  3254. 8*    data%=WinBlk%+92+32*(SelBlk%!0)+20
  3255.  editing single icon
  3256.  IcEd_Icon%>=0 
  3257. ;.      flagptr%=WinBlk%+92+32*IcEd_Icon%+16
  3258. <+      data%=WinBlk%+92+32*IcEd_Icon%+20
  3259. =&      ib%=WinBlk%+92+32*IcEd_Icon%
  3260. >        
  3261. cbp%=WinBlk%!68
  3262.  construct new flags, but do not change "selected" state
  3263. B!flags%=(flagptr%!0) 
  3264.  (1<<21)
  3265. iconselected(IcEdW%,15) 
  3266.  flags%+=(1<<2)
  3267. iconselected(IcEdW%,16) 
  3268.  flags%+=(1<<5)
  3269. iconselected(IcEdW%,17) 
  3270.  flags%+=(1<<3)
  3271. iconselected(IcEdW%,18) 
  3272.  flags%+=(1<<4)
  3273. iconselected(IcEdW%,19) 
  3274.  flags%+=(1<<9)
  3275. iconselected(IcEdW%,20) 
  3276.  flags%+=(1<<7)
  3277. iconselected(IcEdW%,21) 
  3278.  flags%+=(1<<10)
  3279. iconselected(IcEdW%,22) 
  3280.  flags%+=(1<<11)
  3281. iconselected(IcEdW%,39) 
  3282.  flags%+=(1<<22)
  3283. flags%+=(IcEd_Button%<<12)
  3284. flags%+=(IcEd_Esg%<<16)
  3285. iconselected(IcEdW%,41) 
  3286.   flags%+=(1<<6)
  3287.   xsize16%=
  3288. (IcEd_Xsize*16)
  3289.   ysize16%=
  3290. (IcEd_Ysize*16)
  3291.  xsize16%<=0 
  3292.  xsize16%=12*16
  3293.  ysize16%<=0 
  3294.  ysize16%=12*16
  3295.  "Font_FindFont",,IconText%(19),xsize16%,ysize16%,0,0 
  3296.  fhandle%
  3297.  FontUsage%(fhandle%)>0 
  3298. V?    
  3299.  "Font_LoseFont",fhandle% : 
  3300.  font was already in use
  3301.   FontUsage%(fhandle%)+=1
  3302.   flags%+=(fhandle%<<24)
  3303.   flags%+=(IcEd_Fgcol%<<24)
  3304.   flags%+=(IcEd_Bgcol%<<28)
  3305.  (IcEd_Icon%>=0)
  3306. (IcEd_Icon%=-4) 
  3307. iconrelease(flagptr%!0,data%)
  3308. `!  t%=
  3309. iconselected(IcEdW%,12)
  3310. a!  s%=
  3311. iconselected(IcEdW%,13)
  3312. b!  i%=
  3313. iconselected(IcEdW%,14)
  3314.  t%) 
  3315. d=    deflen%=
  3316. ($(IconText%(1)))+1 : 
  3317.  default maximum size
  3318. f$    deflen%=
  3319. ($(IconText%(0)))+1
  3320. i"    maxlen%=
  3321. ($(IconText%(3)))
  3322.     maxlen%=12
  3323.  maxlen%<deflen% 
  3324. nN    maxlen%=deflen%                : 
  3325.  increase max size if text is longer
  3326. o"    
  3327. seticontext(3,
  3328. (maxlen%))
  3329.  i%) 
  3330.  (deflen%>12) 
  3331. rE    
  3332. selecticon(IcEdW%,14,1)    : 
  3333.  make indirected if > 12 chars
  3334. sA    
  3335. seticontext(2,"")          : 
  3336.  default validation string
  3337. iced_shadeicons(14)
  3338.     i%=
  3339.  flags%+=(1<<0)
  3340.  flags%+=(1<<1)
  3341.  flags%+=(1<<8)
  3342.  t%) 
  3343.       data%!0=IconText%(1)
  3344. }D      data%!4=cbp% : 
  3345.  window CBP as default sprite area pointer
  3346. ~        
  3347.       data%!0=IconText%(0)
  3348. "      
  3349. ($(IconText%(2)))>0 
  3350.          data%!4=IconText%(2)
  3351.       
  3352. 2        data%!4=-1 : 
  3353.  empty validation string
  3354.       
  3355.         
  3356.     data%!8=maxlen%
  3357. "      $(data%)=$(IconText%(0))
  3358.         
  3359.       
  3360. $        $(data%)=$(IconText%(1))
  3361.       
  3362.         
  3363.   flagptr%!0=flags%
  3364. iconrealloc(flagptr%,data%)
  3365.  IcEd_Icon% 
  3366.     WinBlk%?36=IcEd_Fgcol%
  3367.     WinBlk%?37=IcEd_Bgcol%
  3368. ,    IcEd_Win%=
  3369. redefinewindow(WinBlk%,1)
  3370. A    
  3371.  do not change text, sprite and indir flags of selection
  3372.     mask%=mask% 
  3373.  &103)
  3374.  NrSelected%>0 
  3375.        
  3376.  i%=0 
  3377.  NrSelected%-1
  3378. H        
  3379. seticonstate(IcEd_Win%,SelBlk%!(4*i%),flags% 
  3380.  mask%,mask%)
  3381.       
  3382.         
  3383.       
  3384. dialogue(9,"")
  3385.         
  3386.  IcEd_Icon%>=0 
  3387. >      IcEd_Icon%=
  3388. redefineicon(IcEd_Win%,IcEd_Icon%,ib%-8)
  3389.         
  3390.       
  3391. dialogue(4,"")
  3392.         
  3393. iconselected(IcEdW%,41) 
  3394.  font count was increased earlier when finding font handle
  3395. font_lose(fhandle%)
  3396. setchanged(
  3397.  *** menu procs ***
  3398. menu_add(text$,submenu%,genmsg%)
  3399.  handle%
  3400.  "MenuUtil_Add",,text$ 
  3401.  handle%
  3402.  submenu%<>-1 
  3403.  "MenuUtil_SubMenu",handle%,submenu%
  3404.  genmsg% 
  3405.  "MenuUtil_Warning",handle%,1
  3406. =handle%
  3407. menu_addwritable(maxlen%,validstr%)
  3408.  handle%
  3409.  "MenuUtil_Add",,"" 
  3410.  handle%
  3411.  "MenuUtil_Writable",,1,maxlen%,validstr%
  3412. =handle%
  3413.  --- shade a whole submenu, but keep it accessible ---
  3414. menu_fadesubmenu(item%,submenu%,switch%)
  3415.  switch% 
  3416.  "MenuUtil_Colours",item%,2,0
  3417.  "MenuUtil_Fade",submenu%,1
  3418.  "MenuUtil_Colours",item%,7,0
  3419.  "MenuUtil_Fade",submenu%,0
  3420. preparemenus
  3421.  "MenuUtil_Initialise",010,0
  3422.  --- custom sprites menu
  3423.  "MenuUtil_New",,"Sprites" 
  3424.  SpritesMenu%
  3425. -item_sprview%=
  3426. menu_add("View/Edit",-1,0)
  3427. -item_sprreload%=
  3428. menu_add("Re-load",-1,0)
  3429. *item_sprreset%=
  3430. menu_add("Reset",-1,0)
  3431.  --- iconbar menu
  3432.  "MenuUtil_New",,Appl$ 
  3433.  MainMenu%
  3434. )item_info%=
  3435. menu_add("Info",InfoW%,0)
  3436.  OSversion%>=300 
  3437. '  item_help%=
  3438. menu_add("Help",-1,0)
  3439.   item_help%=0
  3440. .item_options%=
  3441. menu_add("Options...",-1,0)
  3442. /item_stats%=
  3443. menu_add("Statistics...",-1,0)
  3444. Bitem_customsprites%=
  3445. menu_add("Custom sprites",SpritesMenu%,0)
  3446. %item_quit%=
  3447. menu_add("Quit",-1,0)
  3448.  --- template-name menu
  3449.  "MenuUtil_New",,"   Name:   " 
  3450.  TemplNamemenu%
  3451. +item_templname%=
  3452. menu_addwritable(12,0)
  3453.  --- template submenu
  3454.  "MenuUtil_New",,"" 
  3455.  TemplSubmenu%
  3456. 6item_copytempl%=
  3457. menu_add("Copy",TemplNamemenu%,1)
  3458. :item_renametempl%=
  3459. menu_add("Rename",TemplNamemenu%,1)
  3460. .item_deletetempl%=
  3461. menu_add("Delete",-1,0)
  3462. *item_opentempl%=
  3463. menu_add("Open",-1,0)
  3464. ,item_closetempl%=
  3465. menu_add("Close",-1,0)
  3466. .item_savetempl%=
  3467. menu_add("Save",SaveW%,1)
  3468.  --- export submenu
  3469.  "MenuUtil_New",,"Export" 
  3470.  ExportMenu%
  3471. 8item_exportnames%=
  3472. menu_add("Icon names",ExportW%,1)
  3473. 5item_exporttempl%=
  3474. menu_add("Templates",SaveW%,1)
  3475.  --- template menu
  3476.  "MenuUtil_New",,Appl$ 
  3477.  TemplMenu%
  3478. :item_createtempl%=
  3479. menu_add("Create",TemplNamemenu%,1)
  3480. 0item_template%=
  3481. menu_add("",TemplSubmenu%,0)
  3482. 2item_selalltempl%=
  3483. menu_add("Select all",-1,0)
  3484. 9item_clearseltempl%=
  3485. menu_add("Clear selection",-1,0)
  3486. 2item_export%=
  3487. menu_add("Export",ExportMenu%,1)
  3488. 0item_deleteall%=
  3489. menu_add("Delete all",-1,0)
  3490. 4item_sorttempl%=
  3491. menu_add("Sort templates",-1,0)
  3492. )item_save%=
  3493. menu_add("Save",SaveW%,1)
  3494.  --- direction menu for icon copying
  3495.  "MenuUtil_New",,"Copy" 
  3496.  DirMenu%
  3497. 'item_up%=
  3498. menu_add("Up    ^U",-1,0)
  3499. )item_down%=
  3500. menu_add("Down  ^D",-1,0)
  3501. )item_left%=
  3502. menu_add("Left  ^L",-1,0)
  3503. *item_right%=
  3504. menu_add("Right ^R",-1,0)
  3505.  --- menu for icon renumbering
  3506.  "MenuUtil_New",,"No.:" 
  3507.  IconNrmenu%
  3508. 2item_iconnr%=
  3509. menu_addwritable(4,NumValidStr%)
  3510.  --- "dimension" menu
  3511.  "MenuUtil_New",,"Dim." 
  3512.  DimensionMenu%
  3513. %item_both%=
  3514. menu_add("Both",-1,0)
  3515. "item_xdim%=
  3516. menu_add("X",-1,0)
  3517. "item_ydim%=
  3518. menu_add("Y",-1,0)
  3519.  --- user-template submenu
  3520.  "MenuUtil_New",,"" 
  3521.  UserSubmenu%
  3522. 7item_copyicon%=
  3523. menu_add("Copy      ^C",DirMenu%,0)
  3524.         :item_renumbericon%=
  3525. menu_add("Renumber",IconNrmenu%,0)
  3526. 3item_deleteicon%=
  3527. menu_add("Delete    ^X",-1,0)
  3528. 1item_editicon%=
  3529. menu_add("Edit...   ^E",-1,0)
  3530.  "MenuUtil_Dots",,1
  3531. 3item_align%=
  3532. menu_add("Align     ^J",AlignW%,0)
  3533. 6item_spaceout%=
  3534. menu_add("Space out ^K",SpaceW%,0)
  3535. 3item_frame%=
  3536. menu_add("Frame     ^F",FrameW%,1)
  3537. 9item_minsize%=
  3538. menu_add("Min. size",DimensionMenu%,0)
  3539. 9item_centericon%=
  3540. menu_add("Center",DimensionMenu%,0)
  3541. :item_samesize%=
  3542. menu_add("Same size",DimensionMenu%,0)
  3543.  --- sprite area menu
  3544.  "MenuUtil_New",,"Sprites from" 
  3545.  SpriteAreaMenu% 
  3546. .item_wimparea%=
  3547. menu_add("Wimp area",-1,0)
  3548. 2item_customarea%=
  3549. menu_add("Custom area",-1,0)
  3550.  --- submenus for tidying icons
  3551.  "MenuUtil_New",,"Ensure" 
  3552.  EnsureMenu%
  3553. 2item_tidy1%=
  3554. menu_add("Inside work area",-1,0)
  3555. 5item_tidy2%=
  3556. menu_add("Inside visible area",-1,0)
  3557.  "MenuUtil_New",,"Deleted" 
  3558.  DeletedMenu%
  3559. *item_tidy3%=
  3560. menu_add("Undelete",-1,0)
  3561. 1item_tidy4%=
  3562. menu_add("Undelete & Move",-1,0)
  3563. 'item_tidy5%=
  3564. menu_add("Purge",-1,0)
  3565.  --- "misc" submenu
  3566.  "MenuUtil_New",,"Misc" 
  3567.  MiscMenu%
  3568.     !6item_centerwin%=
  3569. menu_add("Center to screen",-1,0)
  3570.     "?item_spritearea%=
  3571. menu_add("Sprite area",SpriteAreaMenu%,0)
  3572.     #=item_ensureicons%=
  3573. menu_add("Ensure icons",EnsureMenu%,0)
  3574.     $@item_deletedicons%=
  3575. menu_add("Deleted icons",DeletedMenu%,0)
  3576.  --- user-template menu
  3577.  "MenuUtil_New",,"Window" 
  3578.  UserMenu%
  3579.     '5item_createicon%=
  3580. menu_add("Create icon...",-1,0)
  3581.     (+item_icon%=
  3582. menu_add("",UserSubmenu%,0)
  3583.     );item_selallicons%=
  3584. menu_add("Select all       ^A",-1,0)
  3585.     *=item_clearselicons%=
  3586. menu_add("Clear selection  ^Z",-1,0)
  3587.  "MenuUtil_Dots",item_clearselicons%,1
  3588.     ,2item_workarea%=
  3589. menu_add("Work area",WorkW%,1)
  3590.     -:item_editwindow%=
  3591. menu_add("Edit window...   ^W",-1,0)
  3592.     .9item_edittitle%=
  3593. menu_add("Edit title...    ^T",-1,0)
  3594.     /,item_misc%=
  3595. menu_add("Misc",MiscMenu%,0)
  3596.     08item_closewin%=
  3597. menu_add("Close window     ^Q",-1,0)
  3598.  --- menu with icon button-types
  3599.  "MenuUtil_New",,"Button type" 
  3600.  IcButtonMenu%
  3601.  i%=0 
  3602.     4/  dummy%=
  3603. menu_add($(IcButton%+20*i%),-1,0)
  3604.  --- menu with window button-types
  3605.  "MenuUtil_New",,"Button type" 
  3606.  WinButtonMenu%
  3607.  i%=0 
  3608.     90  dummy%=
  3609. menu_add($(WinButton%+20*i%),-1,0)
  3610.  --- actual ESG menu is built when Menu is clicked
  3611. EsgMenu%=0
  3612.  --- actual colour menu is built when Menu is clicked
  3613. ColourMenu%=0
  3614.  --- font menu
  3615. fontmenu
  3616.  --- font size menu
  3617.  "MenuUtil_New",,"Size" 
  3618.  FontSizemenu%
  3619.  "MenuUtil_Add",,"10pt"
  3620.  "MenuUtil_Add",,"12pt"
  3621.  "MenuUtil_Add",,"16pt"
  3622.  "MenuUtil_Add",,"20pt"
  3623.  "MenuUtil_Add",,"24pt"
  3624.  "MenuUtil_Add",,"36pt"
  3625.     I6item_fontsize%=
  3626. menu_addwritable(5,FpNumValidStr%)
  3627.  --- "partial update" submenu
  3628.  "MenuUtil_New",,"Other" 
  3629.  UpdateSubmenu%
  3630.     L(item_updbo%=
  3631. menu_add("Border",-1,0)
  3632.     M(item_updfi%=
  3633. menu_add("Filled",-1,0)
  3634.     N*item_updhc%=
  3635. menu_add("H centre",-1,0)
  3636.     O*item_updvc%=
  3637. menu_add("V centre",-1,0)
  3638.     P-item_updrj%=
  3639. menu_add("R justified",-1,0)
  3640.     Q,item_updnh%=
  3641. menu_add("Needs help",-1,0)
  3642.     R.item_updaa%=
  3643. menu_add("Allow adjust",-1,0)
  3644.     S+item_updhs%=
  3645. menu_add("Half size",-1,0)
  3646.     T(item_updsh%=
  3647. menu_add("Shaded",-1,0)
  3648.  --- "partial update" menu
  3649.  "MenuUtil_New",,"Update" 
  3650.  Updatemenu%
  3651.     W-item_updbt%=
  3652. menu_add("Button type",-1,0)
  3653.     X&item_updesg%=
  3654. menu_add("ESG",-1,0)
  3655.     Y(item_updfg%=
  3656. menu_add("Fg col",-1,0)
  3657.     Z(item_updbg%=
  3658. menu_add("Bg col",-1,0)
  3659.     [(item_updfont%=
  3660. menu_add("Font",-1,0)
  3661.     \;item_updrest%=
  3662. menu_add("Other flags",UpdateSubmenu%,0)
  3663. mainmenu
  3664.  "MenuUtil_Fade",item_stats%,NrTemplates%=0
  3665. menu_fadesubmenu(item_customsprites%,SpritesMenu%,UserSprites%=1)
  3666. templatemenu(
  3667.  xpos%,
  3668.  ypos%,icon%)
  3669. sel_get(TemplW%)
  3670.  (NrSelected%=0) 
  3671.  (icon%>=0) 
  3672.     h"  
  3673. selecticon(TemplW%,icon%,1)
  3674.   SelBlk%!0=icon%
  3675.   NrSelected%=1
  3676.     kD  TemplMenu_Deselect%=
  3677.  deselect icon when menu is removed?
  3678.   TemplMenu_Deselect%=
  3679. menu_fadesubmenu(item_template%,TemplSubmenu%,NrSelected%=0)
  3680.     p    t$=""
  3681.  NrSelected%>1 
  3682.   t$="Selection"
  3683.     s)  
  3684.  "MenuUtil_Text",TemplSubmenu%,t$
  3685.  NrSelected%=1 
  3686.     v(    t$=$(TemplNames%+28*(SelBlk%!0))
  3687.     x1  
  3688.  "MenuUtil_Text",TemplSubmenu%,"Template"
  3689.  "MenuUtil_Fade",item_copytempl%,NrSelected%<>1
  3690.  "MenuUtil_Fade",item_renametempl%,NrSelected%<>1
  3691. SelFname$=t$
  3692.  NrSelected%>1 
  3693.     ~3  
  3694.  "MenuUtil_Text",item_template%,"Selection"
  3695.  "MenuUtil_Text",item_template%,"Template '"+t$+"'"
  3696.  "MenuUtil_Fade",item_selalltempl%,NrTemplates%=0
  3697.  "MenuUtil_Fade",item_clearseltempl%,NrSelected%=0
  3698.  "MenuUtil_Fade",item_deleteall%,NrTemplates%=0
  3699.  "MenuUtil_Fade",item_sorttempl%,NrTemplates%=0
  3700. menu_fadesubmenu(item_export%,ExportMenu%,NrTemplates%=0)
  3701.  "MenuUtil_Fade",item_save%,NrTemplates%=0
  3702. QuitAfterSave%=
  3703. xpos%-=64
  3704.  NrSelected%=0 
  3705.   ypos%+=22
  3706.   ypos%+=66
  3707. usermenu(
  3708.  xpos%,
  3709.  ypos%,window%,icon%)
  3710.  t$,st$
  3711. sel_get(window%)
  3712.  (NrSelected%=0) 
  3713.  (icon%>=0) 
  3714.   SelBlk%!0=icon%
  3715.   NrSelected%=1
  3716. menu_fadesubmenu(item_icon%,UserSubmenu%,NrSelected%=0)
  3717.  NrSelected% 
  3718.     t$="No icon"
  3719.     st$=t$
  3720.      t$="Icon #"+
  3721. (SelBlk%!0)
  3722.     st$=t$
  3723.     t$="Selection"
  3724. #    st$=
  3725. (NrSelected%)+" icons"
  3726.  "MenuUtil_Text",UserSubmenu%,st$
  3727.  "MenuUtil_Fade",item_renumbericon%,NrSelected%=0
  3728.  "MenuUtil_Fade",item_align%,NrSelected%<2
  3729.  "MenuUtil_Fade",item_spaceout%,NrSelected%<2
  3730.  "MenuUtil_Fade",item_frame%,NrSelected%<2
  3731.  "MenuUtil_Text",item_iconnr%,
  3732. (NextIconNr%)
  3733.  "MenuUtil_Fade",item_samesize%,NrSelected%<2
  3734. WinBlk%!0=window%
  3735.  "Wimp_GetWindowInfo",,WinBlk%
  3736.  WinBlk%!68=1 
  3737.  "MenuUtil_TickOnly",SpriteAreaMenu%,0
  3738.  "MenuUtil_TickOnly",SpriteAreaMenu%,1
  3739.  "MenuUtil_Text",item_icon%,t$
  3740.  "MenuUtil_Fade",item_selallicons%,WinBlk%!88=0
  3741.  "MenuUtil_Fade",item_clearselicons%,NrSelected%=0
  3742. menu_fadesubmenu(item_ensureicons%,EnsureMenu%,WinBlk%!88=0)
  3743.  "Wimp_WhichIcon",window%,SelBlk2%,1<<23,1<<23 : 
  3744.  any deleted icons?
  3745. menu_fadesubmenu(item_deletedicons%,DeletedMenu%,SelBlk2%!0=-1)
  3746. menu_fadesubmenu(item_spritearea%,SpriteAreaMenu%,UserSprites%=1)
  3747. xpos%-=64
  3748.  NrSelected%=0 
  3749.   ypos%+=22
  3750.   ypos%+=66
  3751. icbuttonmenu(
  3752.  xpos%,
  3753.  ypos%)
  3754.  "MenuUtil_TickOnly",IcButtonMenu%,IcEd_Button%
  3755. xpos%+=16
  3756. ypos%+=22+IcEd_Button%*44
  3757. winbuttonmenu(
  3758.  xpos%,
  3759.  ypos%)
  3760.  "MenuUtil_TickOnly",WinButtonMenu%,WinEd_Button%
  3761. xpos%+=16
  3762. ypos%+=22+WinEd_Button%*44
  3763. esgmenu(
  3764.  xpos%,
  3765.  ypos%)
  3766.  EsgMenu%<>0 
  3767.  "MenuUtil_Delete",EsgMenu%,
  3768.  Support%=2 
  3769.  "MenuUtil_New",,"ESG" 
  3770.  EsgMenu%
  3771. .  dummy%=
  3772. menu_addwritable(3,NumValidStr%)
  3773.  "MenuUtil_Text",,
  3774. (IcEd_Esg%)
  3775. *  dummy%=
  3776. menu_add("16 (Action)",-1,0)
  3777. 2  dummy%=
  3778. menu_add("18 (Default action)",-1,0)
  3779. ,  dummy%=
  3780. menu_add("19 (Writable)",-1,0)
  3781. +  dummy%=
  3782. menu_add("20 (Display)",-1,0)
  3783. -  dummy%=
  3784. menu_add("21 (Group box)",-1,0)
  3785. 0  dummy%=
  3786. menu_add("24 (24bit colour)",-1,0)
  3787. *  dummy%=
  3788. menu_add("25 (Slider)",-1,0)
  3789.   ypos%+=22
  3790.  "MenuUtil_New",,"ESG" 
  3791.  EsgMenu%
  3792.  i%=0 
  3793. $    dummy%=
  3794. menu_add(
  3795. (i%),-1,0)
  3796.   ypos%+=22
  3797.  IcEd_Esg%<=15 
  3798. 1    
  3799.  "MenuUtil_TickOnly",EsgMenu%,IcEd_Esg%
  3800.     ypos%+=IcEd_Esg%*44
  3801. xpos%+=16
  3802. colourmenu(
  3803.  xpos%,
  3804.  ypos%,window%,icon%)
  3805.  i%,flags%,current%,bigrange%,transp%
  3806.  ColourMenu%<>0 
  3807.  "MenuUtil_Delete",ColourMenu%,
  3808.  window% 
  3809.  IcEdW%
  3810.  icon% 
  3811. %      
  3812.  34 : current%=IcEd_Fgcol%
  3813. %      
  3814.  37 : current%=IcEd_Bgcol%
  3815.         
  3816.     bigrange%=
  3817.     transp%=
  3818.  WinEdW%
  3819. *    bigrange%=
  3820. iconselected(WinEdW%,9)
  3821. %    transp%=(icon%=27)
  3822. (icon%=39)
  3823. )    current%=WinEd_Col%((icon%-27)
  3824.  bigrange% 
  3825.  colour menu for colour numbers 0-255 (GCOL colours)
  3826.  "MenuUtil_New",,"Col" 
  3827.  ColourMenu%
  3828. .  dummy%=
  3829. menu_addwritable(4,NumValidStr%)
  3830.  "MenuUtil_Text",,
  3831. (current%)
  3832.  transp% 
  3833. !    
  3834.  "MenuUtil_Add",,"None"
  3835. (    
  3836.  "MenuUtil_Tick",,current%=255
  3837.  colour menu for colour numbers 0-15
  3838.  "MenuUtil_New",,"Col" 
  3839.  ColourMenu%
  3840.  i%=0 
  3841.      
  3842.  "MenuUtil_Add",,
  3843. 4    
  3844.  "MenuUtil_Colours",,InverseColour%(i%),i%
  3845.  transp% 
  3846.  "MenuUtil_Dots",,1
  3847. !    
  3848.  "MenuUtil_Add",,"None"
  3849.  current%=255 
  3850. -    
  3851.  "MenuUtil_TickOnly",ColourMenu%,16
  3852. 3    
  3853.  "MenuUtil_TickOnly",ColourMenu%,current%
  3854. xpos%+=16
  3855. ypos%+=22
  3856.  bigrange%) 
  3857.  current%=255 
  3858.     ypos%+=16*44+22
  3859.     ypos%+=current%*44
  3860. fontmenu
  3861.  next%,font$,fam$,style$,p%,submenu%,item%
  3862.  "MenuUtil_New",,"Font" 
  3863.  FontMenu%
  3864. fam$=""
  3865. next%=0
  3866.   f$=
  3867. 40," ")
  3868.  "Font_ListFonts",,FontData%,next%,-1 
  3869.  ,,next%
  3870.  next%<>-1 
  3871.     f$=$(FontData%)
  3872.     p%=
  3873. f$,".")
  3874.  p%>0 
  3875.       style$=
  3876. f$,p%+1)
  3877.       f$=
  3878. f$,p%-1)
  3879. ,        
  3880.       style$="(Regular)"
  3881. .        
  3882. /$    
  3883.  (f$<>fam$) 
  3884.  (next%<>-1) 
  3885.       
  3886.  new font family
  3887.       fam$=f$
  3888. 22      
  3889.  "MenuUtil_Add",FontMenu%,fam$ 
  3890.  item%
  3891. 3,      
  3892.  "MenuUtil_New",,fam$ 
  3893.  submenu%
  3894. 4.      
  3895.  "MenuUtil_SubMenu",item%,submenu%
  3896. 5        
  3897. 6)    
  3898.  "MenuUtil_Add",submenu%,style$
  3899.  next%=-1
  3900. fontsizemenu(
  3901.  xpos%,
  3902.  ypos%,window%,icon%)
  3903.  icon%=48 
  3904.  "MenuUtil_Text",item_fontsize%,
  3905. (IcEd_Xsize),5)
  3906.  "MenuUtil_Text",item_fontsize%,
  3907. (IcEd_Ysize),5)
  3908. ypos%+=7*44
  3909. updatemenu(
  3910.  xpos%,
  3911.  ypos%,window%,icon%)
  3912.  font%
  3913. F"font%=
  3914. iconselected(IcEdW%,41)
  3915.  "MenuUtil_Fade",item_updfg%,font%
  3916.  "MenuUtil_Fade",item_updbg%,font%
  3917.  "MenuUtil_Fade",item_updfont%,
  3918.  font%
  3919. ypos%+=22
  3920. createmenu(xpos%,ypos%,window%,icon%)
  3921. LastMenu_X%=xpos%
  3922. LastMenu_Y%=ypos%
  3923. LastMenu_Win%=window%
  3924. LastMenu_Icon%=icon%
  3925. LastMenu%=-1
  3926.  window% 
  3927. mainmenu
  3928.     LastMenu%=MainMenu%
  3929.  TemplW%
  3930. X(    
  3931. templatemenu(xpos%,ypos%,icon%)
  3932.     LastMenu%=TemplMenu%
  3933.  IcEdW%
  3934.  icon% 
  3935.       
  3936.  9,10
  3937.         
  3938.  IcEd_Icon%=-1 
  3939. ^4          
  3940. updatemenu(xpos%,ypos%,window%,icon%)
  3941. _#          LastMenu%=Updatemenu%
  3942.         
  3943.       
  3944. b&        
  3945. icbuttonmenu(xpos%,ypos%)
  3946. c#        LastMenu%=IcButtonMenu%
  3947.       
  3948. e!        
  3949. esgmenu(xpos%,ypos%)
  3950.         LastMenu%=EsgMenu%
  3951.       
  3952.  34,37
  3953. h2        
  3954. colourmenu(xpos%,ypos%,window%,icon%)
  3955. i!        LastMenu%=ColourMenu%
  3956.       
  3957.  45,46
  3958.         xpos%+=16
  3959.         ypos%+=22
  3960.         LastMenu%=FontMenu%
  3961.       
  3962.  48,51
  3963. o4        
  3964. fontsizemenu(xpos%,ypos%,window%,icon%)
  3965. p#        LastMenu%=FontSizemenu%
  3966. q        
  3967.  WinEdW%
  3968.  icon% 
  3969.       
  3970. u'        
  3971. winbuttonmenu(xpos%,ypos%)
  3972. v$        LastMenu%=WinButtonMenu%
  3973. w       
  3974.  27,31,35,39,43,47,51
  3975. x2        
  3976. colourmenu(xpos%,ypos%,window%,icon%)
  3977. y!        LastMenu%=ColourMenu%
  3978. z        
  3979. |&    
  3980. whichtemplate(window%)>=0 
  3981. }.      
  3982. usermenu(xpos%,ypos%,window%,icon%)
  3983.       LastMenu%=UserMenu%
  3984.         
  3985.  LastMenu%<>-1 
  3986.   ScrapBlk%!0=xpos%
  3987.   ScrapBlk%!4=ypos%
  3988.   ScrapBlk%!12=window%
  3989.  "MenuUtil_Show",LastMenu%,ScrapBlk%
  3990.  create a window-menu
  3991. createwinmenu(window%,menuwin%,xofs%,yofs%)
  3992.  "Wimp_GetPointerInfo",,PtrInfo%
  3993.  "Wimp_CreateMenu",,menuwin%,PtrInfo%!0+xofs%,PtrInfo%!4+yofs%
  3994. LastMenu_Win%=window%
  3995. LastMenu_Icon%=-1
  3996.  *** drag procs; for moving and resizing icons ***
  3997. finishdrag(xmin%,ymin%,xmax%,ymax%)
  3998.  win0x%,win0y%,i%,iconblk%,inbox%
  3999. setmouseshape(0)                  : 
  4000.  restore default pointer shape
  4001.  xmin%>xmax% 
  4002.  xmin%,xmax%
  4003.  ymin%>ymax% 
  4004.  ymin%,ymax%
  4005.  "Wimp_GetPointerInfo",,PtrInfo%
  4006.  Drag_Type% 
  4007.  0,1 : 
  4008.  move / resize icon(s)
  4009. *    
  4010. whichtemplate(PtrInfo%!12)>=0 
  4011.       WinBlk%!0=PtrInfo%!12
  4012. *      
  4013.  "Wimp_GetWindowInfo",,WinBlk%
  4014. %      win0x%=WinBlk%!4-WinBlk%!20
  4015. &      win0y%=WinBlk%!16-WinBlk%!24
  4016. I      xmin%-=win0x% : 
  4017.  translate from screen coords to window coords
  4018.       ymin%-=win0y%
  4019.       xmax%-=win0x%
  4020.       ymax%-=win0y%
  4021. O      
  4022. moveresize(Drag_Win%,Drag_Icon%,PtrInfo%!12,xmin%,ymin%,xmax%,ymax%)
  4023. A      
  4024. setcaret(PtrInfo%!12,-1) : 
  4025.  move focus to this window
  4026.         
  4027. -      
  4028.  DeleteOutside% 
  4029.  (Drag_Type%=0) 
  4030. D        
  4031.  moved icons outside window - delete them if option set
  4032. "        
  4033.  i%=0 
  4034.  NrSelected%-1
  4035. 7          
  4036. deleteicon(Drag_Win%,SelBlk%!(4*i%),1,1)
  4037.         
  4038.       
  4039.         
  4040.  2,3 : 
  4041.  drag-select icons (with Select/Adjust)
  4042.     WinBlk%!0=Drag_Win%
  4043. (    
  4044.  "Wimp_GetWindowInfo",,WinBlk%
  4045. #    win0x%=WinBlk%!4-WinBlk%!20
  4046. $    win0y%=WinBlk%!16-WinBlk%!24
  4047.     xmin%-=win0x%
  4048.     xmax%-=win0x%
  4049.     ymin%-=win0y%
  4050.     ymax%-=win0y%
  4051. >    
  4052.  (WinBlk%!88>0) 
  4053.  ((xmax%-xmin%)+(ymax%-ymin%)>=32) 
  4054.       
  4055.  i%=0 
  4056.  WinBlk%!88-1
  4057. %        iconblk%=WinBlk%+92+i%*32
  4058. ;        inbox%=(iconblk%!0<xmax%) 
  4059.  (iconblk%!8>=xmin%)
  4060. E        inbox%=inbox% 
  4061.  (iconblk%!4<ymax%) 
  4062.  (iconblk%!12>=ymin%)
  4063. )        
  4064.  inbox% 
  4065.  (i%<>Drag_Icon%) 
  4066.           
  4067.  Drag_Type%=2 
  4068. +            
  4069. selecticon(Drag_Win%,i%,1)
  4070.           
  4071. 3            
  4072. seticonstate(Drag_Win%,i%,1<<21,0)
  4073.           
  4074.         
  4075.       
  4076.         
  4077.  4 : 
  4078.  drag from save-box
  4079. .    
  4080.  DragASprite% 
  4081.  "DragASprite_Stop"
  4082.     Blk%!0=256
  4083.     Blk%!12=0
  4084.     Blk%!16=1
  4085.     Blk%!20=PtrInfo%!12
  4086.     Blk%!24=PtrInfo%!16
  4087.     Blk%!28=PtrInfo%!0
  4088.     Blk%!32=PtrInfo%!4
  4089.  Drag_Win% 
  4090.       
  4091.  SaveW%
  4092.         
  4093.  Exporting% 
  4094.           Blk%!36=1
  4095.           Blk%!40=&FFF
  4096.         
  4097. G          Blk%!36=20+112*NrTemplates% : 
  4098.  low estimate of file size
  4099.           Blk%!40=&FEC
  4100.         
  4101. .        $(Blk%+44)=
  4102. leafname($(FileName%))
  4103.       
  4104.  ExportW%
  4105.         Blk%!36=1
  4106.         
  4107.  ExportType% 
  4108.            
  4109.  0 : Blk%!40=&FFB
  4110. "          
  4111.  1,2 : Blk%!40=&FFF
  4112.         
  4113. 0        $(Blk%+44)=
  4114. leafname($(ExportName%))
  4115.         
  4116. =    
  4117.  "Wimp_SendMessage",17,Blk%,PtrInfo%!12,PtrInfo%!16
  4118.  5,6,7
  4119. L    
  4120.  window move/resize/workresize - do nothing (no drag event anyway!)
  4121. Drag_Type%=-1
  4122. initdrag(type%,window%,icon%,box0x%,box0y%)
  4123.  "OS_Byte",161,&1C 
  4124.  ,,b% : 
  4125.  read "dragasprite" bit in CMOS RAM (RO3)
  4126. DragASprite%=(b% 
  4127.  2)<>0
  4128.  DragASprite% 
  4129.  (type%=4) 
  4130.   ScrapBlk%!0=window%
  4131.   ScrapBlk%!4=2
  4132.  "Wimp_GetIconState",,ScrapBlk%
  4133.  "DragASprite_Start",&A1,1,ScrapBlk%!28,DragBlk%+8,DragBlk%+24
  4134.  "Wimp_DragBox",1,DragBlk%
  4135. =Drag_Type%=type%   : 
  4136.  is not the same as Wimp drag type!
  4137. Drag_Win%=window%
  4138. Drag_Icon%=icon%
  4139. DDrag_Box0x%=box0x% : 
  4140.  window coords of bottomleft corner of box
  4141. Drag_Box0y%=box0y%
  4142. ,Drag_BoxSizex%=
  4143. (DragBlk%!16-DragBlk%!8)
  4144. -Drag_BoxSizey%=
  4145. (DragBlk%!20-DragBlk%!12)
  4146.  "Wimp_GetPointerInfo",,PtrInfo%
  4147. Drag_Ptrx%=PtrInfo%!0
  4148. Drag_Ptry%=PtrInfo%!4
  4149. abortdrag
  4150.  DragASprite% 
  4151.  (Drag_Type%=4) 
  4152.  "DragASprite_Stop"
  4153.  "Wimp_DragBox",,-1
  4154. setmouseshape(0)          : 
  4155.  restore default pointer shape
  4156.  Drag_Type%=7 
  4157.  restore work area size
  4158.   WinBlk%!0=Drag_Win%
  4159.  "Wimp_GetWindowState",,WinBlk%
  4160.   WinBlk%!52=Drag_WAmaxX%
  4161.   WinBlk%!48=Drag_WAminY%
  4162. *  Drag_Win%=
  4163. redefinewindow(WinBlk%,
  4164. Drag_Type%=-1
  4165. startwindowmove(window%)
  4166. DragBlk%!0=window%
  4167. DragBlk%!4=1
  4168. initdrag(5,-1,-1,0,0)
  4169. startwindowresize(window%)
  4170. DragBlk%!0=window%
  4171. DragBlk%!4=2
  4172. initdrag(6,-1,-1,0,0)
  4173. startworkarearesize(window%)
  4174. WinBlk%!0=window%
  4175.  "Wimp_GetWindowInfo",,WinBlk%
  4176.  LDrag_WAmaxX%=WinBlk%!52 : 
  4177.  save, so it can be restored when drag aborts
  4178. Drag_WAminY%=WinBlk%!48
  4179. "BWinBlk%!52=2000  : 
  4180.  temporarily make work area very large, so
  4181. #NWinBlk%!48=-2000 : 
  4182.  window-resize drag that follows is not confined by it
  4183. $&window%=
  4184. redefinewindow(WinBlk%,
  4185. setcaret(window%,-1)
  4186. DragBlk%!0=window%
  4187. DragBlk%!4=2
  4188. initdrag(7,window%,-1,0,0)
  4189. starticondrag(button%,window%,icon%)
  4190.  button% 
  4191.  1,256
  4192. sel_get(window%)
  4193.  NrSelected%>0 
  4194. 0&      
  4195. starticonresize(window%,-1)
  4196. 1        
  4197. 26      
  4198.  icon%>=0 
  4199. starticonresize(window%,icon%)
  4200. 3        
  4201.  4,1024
  4202. sel_get(window%)
  4203.  NrSelected%>0 
  4204. 7$      
  4205. starticonmove(window%,-1)
  4206. 8        
  4207. 94      
  4208.  icon%>=0 
  4209. starticonmove(window%,icon%)
  4210. :        
  4211. starticonmove(window%,icon%)
  4212.  win0x%,win0y%,xmin%,xmax%,ymin%,ymax%
  4213. WinBlk%!0=window%
  4214.  "Wimp_GetWindowState",,WinBlk%
  4215. win0x%=WinBlk%!4-WinBlk%!20
  4216. C win0y%=WinBlk%!16-WinBlk%!24
  4217.  icon%>=0 
  4218. E6  SelBlk%!0=icon% : 
  4219.  simulate selection of 1 icon
  4220.   NrSelected%=1
  4221. sel_get(window%)
  4222. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  4223.  "Wimp_GetPointerInfo",,PtrInfo%
  4224. DragBlk%!4=5
  4225. DragBlk%!8=xmin%+win0x%
  4226. DragBlk%!12=ymin%+win0y%
  4227. DragBlk%!16=xmax%+win0x%
  4228. DragBlk%!20=ymax%+win0y%
  4229. Q%DragBlk%!24=DragBlk%!8-PtrInfo%!0
  4230. R&DragBlk%!28=DragBlk%!12-PtrInfo%!4
  4231. S4DragBlk%!32=ScreenSize_X%+DragBlk%!16-PtrInfo%!0
  4232. T4DragBlk%!36=ScreenSize_Y%+DragBlk%!20-PtrInfo%!4
  4233. initdrag(0,window%,icon%,xmin%,ymin%)
  4234. setmouseshape(1)
  4235. starticonresize(window%,icon%)
  4236.  ibxmin%,ibxmax%,ibymin%,ibymax%
  4237.  pbxmin%,pbxmax%,pbymin%,pbymax%
  4238.  a,b,c
  4239.  ibsizex%,ibsizey%,minsizex%,minsizey%
  4240.  shape%
  4241.  win0x%,win0y%,xmin%,xmax%,ymin%,ymax%
  4242. WinBlk%!0=window%
  4243.  "Wimp_GetWindowState",,WinBlk%
  4244. win0x%=WinBlk%!4-WinBlk%!20
  4245. c win0y%=WinBlk%!16-WinBlk%!24
  4246.  icon%>=0 
  4247. e6  SelBlk%!0=icon% : 
  4248.  simulate selection of 1 icon
  4249.   NrSelected%=1
  4250. sel_get(window%)
  4251. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  4252. kFibxmin%=win0x%+xmin% : 
  4253.  for initial box, convert to screen coords
  4254. ibymin%=win0y%+ymin%
  4255. ibxmax%=win0x%+xmax%
  4256. ibymax%=win0y%+ymax%
  4257. ibsizex%=xmax%-xmin%
  4258. ibsizey%=ymax%-ymin%
  4259.  at first, set parent box equal to initial box
  4260. pbxmin%=ibxmin%
  4261. pbymin%=ibymin%
  4262. pbxmax%=ibxmax%
  4263. pbymax%=ibymax%
  4264.  fixed minimum size of drag box (very difficult to calculate!)
  4265. minsizex%=4
  4266. minsizey%=4
  4267.  minsizex%>ibsizex% 
  4268.  minsizex%=ibsizex%
  4269.  minsizey%>ibsizey% 
  4270.  minsizey%=ibsizey%
  4271.  get position of window on screen
  4272. WinBlk%!0=window%
  4273.  "Wimp_GetWindowState",,WinBlk%
  4274.  determine which side to drag - test mouse position relative to
  4275.  diagonals of box
  4276.  diagonal 1 (bottomleft-topright) y = a*x + b
  4277.  diagonal 2 (topleft-bottomright) y = -a*x + c
  4278. a=ibsizey%/ibsizex%
  4279. b=ibymin%-a*ibxmin%
  4280. c=ibymax%+a*ibxmin%
  4281.  "Wimp_GetPointerInfo",,PtrInfo%
  4282.  PtrInfo%!4>(a*(PtrInfo%!0)+b) 
  4283.  above diagonal 1
  4284.  PtrInfo%!4>(-a*(PtrInfo%!0)+c) 
  4285. *    
  4286.  above diagonal 2 - drag top side
  4287. :    
  4288.  WinBlk%!16>ibymax% 
  4289.  pbymax%=WinBlk%!16-ibsizey%
  4290.     pbymin%+=minsizey%
  4291.     shape%=2
  4292. ?    
  4293.  ibymin%,ibymax% : 
  4294.  top side of box must be "rubber"
  4295. +    
  4296.  below diagonal 2 - drag left side
  4297. 8    
  4298.  WinBlk%!4<ibxmin% 
  4299.  pbxmin%=WinBlk%!4+ibsizex%
  4300.     pbxmax%-=minsizex%
  4301.     shape%=5
  4302. @    
  4303.  ibxmin%,ibxmax% : 
  4304.  left side of box must be "rubber"
  4305.  below diagonal 1
  4306.  PtrInfo%!4>(-a*(PtrInfo%!0)+c) 
  4307. ,    
  4308.  above diagonal 2 - drag right side
  4309. 1    
  4310.  pbxmax%<WinBlk%!12 
  4311.  pbxmax%=WinBlk%!12
  4312. #    pbxmin%-=ibsizex%-minsizex%
  4313.     shape%=3
  4314. -    
  4315.  below diagonal 2 - drag bottom side
  4316. /    
  4317.  pbymin%>WinBlk%!8 
  4318.  pbymin%=WinBlk%!8
  4319. #    pbymax%+=ibsizey%-minsizey%
  4320.     shape%=4
  4321. DragBlk%!4=6
  4322. DragBlk%!8=ibxmin%
  4323. DragBlk%!12=ibymin%
  4324. DragBlk%!16=ibxmax%
  4325. DragBlk%!20=ibymax%
  4326. DragBlk%!24=pbxmin%
  4327. DragBlk%!28=pbymin%
  4328. DragBlk%!32=pbxmax%
  4329. DragBlk%!36=pbymax%
  4330. initdrag(1,window%,icon%,xmin%,ymin%)
  4331. setmouseshape(shape%)
  4332. dragselect(button%)
  4333.  Drag_Type%<0 
  4334.  "Wimp_GetPointerInfo",,PtrInfo%
  4335.   DragBlk%!4=6
  4336.   DragBlk%!8=PtrInfo%!0
  4337.   DragBlk%!12=PtrInfo%!4
  4338.   DragBlk%!16=PtrInfo%!0
  4339.   DragBlk%!20=PtrInfo%!4
  4340.   WinBlk%!0=PtrInfo%!12
  4341.  "Wimp_GetWindowState",,WinBlk%
  4342.   DragBlk%!24=WinBlk%!4
  4343.   DragBlk%!28=WinBlk%!8
  4344.   DragBlk%!32=WinBlk%!12
  4345.   DragBlk%!36=WinBlk%!16
  4346.  button%=1 
  4347. E    
  4348. initdrag(3,PtrInfo%!12,PtrInfo%!16,0,0) : 
  4349.  drag with Adjust
  4350. E    
  4351. initdrag(2,PtrInfo%!12,PtrInfo%!16,0,0) : 
  4352.  drag with Select
  4353. startsavedrag(window%)
  4354.  win0x%,win0y%
  4355. WinBlk%!0=window%
  4356.  "Wimp_GetWindowState",,WinBlk%
  4357. win0x%=WinBlk%!4-WinBlk%!20
  4358.  win0y%=WinBlk%!16-WinBlk%!24
  4359. ScrapBlk%!0=window%
  4360. ScrapBlk%!4=2
  4361.  "Wimp_GetIconState",,ScrapBlk%
  4362. DragBlk%!4=5
  4363. !DragBlk%!8=ScrapBlk%!8+win0x%
  4364. #DragBlk%!12=ScrapBlk%!12+win0y%
  4365. #DragBlk%!16=ScrapBlk%!16+win0x%
  4366. #DragBlk%!20=ScrapBlk%!20+win0y%
  4367.  "Wimp_GetPointerInfo",,PtrInfo%
  4368. %DragBlk%!24=DragBlk%!8-PtrInfo%!0
  4369. &DragBlk%!28=DragBlk%!12-PtrInfo%!4
  4370. 4DragBlk%!32=ScreenSize_X%+DragBlk%!16-PtrInfo%!0
  4371. 4DragBlk%!36=ScreenSize_Y%+DragBlk%!20-PtrInfo%!4
  4372. initdrag(4,window%,2,0,0)
  4373.  --- move or resize icons, based on new coords of box ---
  4374. moveresize(oldwin%,icon%,newwin%,xmin%,ymin%,xmax%,ymax%)
  4375.  oldxmin%,oldymin%,oldxmax%,oldymax%
  4376.  xscale,yscale,new%,i%
  4377.  icon%>=0 
  4378. 6  SelBlk%!0=icon% : 
  4379.  simulate selection of 1 icon
  4380.   NrSelected%=1
  4381. sel_get(oldwin%)
  4382.  NrSelected%>0 
  4383. sel_box(oldwin%,oldxmin%,oldymin%,oldxmax%,oldymax%)
  4384.  calculate scaling factors (will be 1 for move)
  4385. .  xscale=(xmax%-xmin%)/(oldxmax%-oldxmin%)
  4386. .  yscale=(ymax%-ymin%)/(oldymax%-oldymin%)
  4387.  i%=0 
  4388.  NrSelected%-1
  4389.     IconBlk%!0=oldwin%
  4390. !    IconBlk%!4=SelBlk%!(4*i%)
  4391. (    
  4392.  "Wimp_GetIconState",,IconBlk%
  4393. <    IconBlk%!8=xmin%+
  4394. ((IconBlk%!8-oldxmin%)*xscale+0.5)
  4395. >    IconBlk%!12=ymin%+
  4396. ((IconBlk%!12-oldymin%)*yscale+0.5)
  4397. >    IconBlk%!16=xmin%+
  4398. ((IconBlk%!16-oldxmin%)*xscale+0.5)
  4399. >    IconBlk%!20=ymin%+
  4400. ((IconBlk%!20-oldymin%)*yscale+0.5)
  4401.  oldwin%=newwin% 
  4402. (      
  4403.  move / resize in same window
  4404. =      new%=
  4405. redefineicon(oldwin%,SelBlk%!(4*i%),IconBlk%)
  4406.         
  4407. 3      
  4408.  move to other other window = copy icons
  4409.       IconBlk%!4=newwin%
  4410. H      
  4411. iconrealloc(IconBlk%+24,IconBlk%+28) : 
  4412.  copy indirected data
  4413. &      new%=
  4414. createicon(IconBlk%+4)
  4415.         
  4416.  *** procs for dialogue and reporting errors ***
  4417. errbox(err$,boxes%)
  4418. ErrBlk%!0=0
  4419. $(ErrBlk%+4)=err$+
  4420.  "Wimp_ReportError",ErrBlk%,boxes%,Appl$ 
  4421.  ,click%
  4422. =(click%=1)
  4423. error(forcequit%)
  4424.  button%
  4425.  "Wimp_CloseDown" : 
  4426.  "Hourglass_Smash"
  4427.  forcequit% 
  4428.   button%=2
  4429.   button%=3
  4430. errbox(
  4431. $+" (line "+
  4432. )+")",button%)) 
  4433.  "Wimp_CloseDown"
  4434. complain(msg$)
  4435.  dummy%
  4436. dummy%=
  4437. errbox(msg$,17)
  4438. dialogue(no%,arg1$)
  4439.  b1$,b2$,b3$,mask%,xpos%,ypos%
  4440. b1$=""
  4441. b2$=""
  4442. b3$=""
  4443.  no% 
  4444. $'    $Dial_Msg%=
  4445. msg_lookup0("MOD0")
  4446. %     b1$=
  4447. msg_lookup0("SAVE")
  4448. &     b2$=
  4449. msg_lookup0("DCRD")
  4450. '     b3$=
  4451. msg_lookup0("CANC")
  4452. )'    $Dial_Msg%=
  4453. msg_lookup0("MOD0")
  4454. *     b1$=
  4455. msg_lookup0("DALL")
  4456. +     b3$=
  4457. msg_lookup0("CANC")
  4458. -'    $Dial_Msg%=
  4459. msg_lookup0("MOD0")
  4460. .     b1$=
  4461. msg_lookup0("LNEW")
  4462. /     b3$=
  4463. msg_lookup0("CANC")
  4464. 1-    $Dial_Msg%=
  4465. msg_lookup1("NORM",arg1$)
  4466.     b2$=
  4467. msg_lookup0("OK")
  4468. 4'    $Dial_Msg%=
  4469. msg_lookup0("NUPD")
  4470.     b2$=
  4471. msg_lookup0("OK")
  4472. 7'    $Dial_Msg%=
  4473. msg_lookup0("NOSH")
  4474.     b2$=
  4475. msg_lookup0("OK")
  4476. :'    $Dial_Msg%=
  4477. msg_lookup0("NOCH")
  4478.     b2$=
  4479. msg_lookup0("OK")
  4480. =-    $Dial_Msg%=
  4481. msg_lookup1("TIDY",arg1$)
  4482.     b2$=
  4483. msg_lookup0("OK")
  4484. @'    $Dial_Msg%=
  4485. msg_lookup0("MOD0")
  4486. A     b1$=
  4487. msg_lookup0("DCRD")
  4488. B     b3$=
  4489. msg_lookup0("CANC")
  4490. D'    $Dial_Msg%=
  4491. msg_lookup0("NSEL")
  4492.     b2$=
  4493. msg_lookup0("OK")
  4494. G'    $Dial_Msg%=
  4495. msg_lookup0("NFRM")
  4496.     b2$=
  4497. msg_lookup0("OK")
  4498. $Dial_Button1%=b1$
  4499. $Dial_Button2%=b2$
  4500. $Dial_Button3%=b3$
  4501. M)mask%=(1<<2)+(1<<5)+(1<<22)+(&FF<<24)
  4502. (b1$)=0 
  4503.  grey colour -> invisible%
  4504. seticonstate0(DialW%,1,(1<<22)+(&11<<24),mask%)
  4505. seticonstate0(DialW%,1,Dial_ButtonCol1%,mask%)
  4506. (b2$)=0 
  4507. seticonstate0(DialW%,2,(1<<22)+(&11<<24),mask%)
  4508. seticonstate0(DialW%,2,Dial_ButtonCol2%,mask%)
  4509. (b3$)=0 
  4510. seticonstate0(DialW%,3,(1<<22)+(&11<<24),mask%)
  4511. seticonstate0(DialW%,3,Dial_ButtonCol3%,mask%)
  4512. ScrapBlk%!0=DialW%
  4513.  "Wimp_GetWindowState",,ScrapBlk%
  4514. `8xpos%=(ScreenSize_X%-(ScrapBlk%!12-ScrapBlk%!4)) 
  4515. a8ypos%=(ScreenSize_Y%+(ScrapBlk%!16-ScrapBlk%!8)) 
  4516.  "Wimp_CreateMenu",,DialW%,xpos%,ypos%
  4517. LastDialogue%=no%
  4518.  *** heap procs ***
  4519. heap_init
  4520. i>Heap%=
  4521.  heap starts just after end of allocated memory
  4522.  "OS_ReadMemMapInfo" 
  4523.  PageSize%
  4524.  enlarge wimpslot (1 page) and create private heap in new memory
  4525. SlotSize%=Heap%-&8000
  4526.  "Wimp_SlotSize",SlotSize%+PageSize%,-1 
  4527.  SlotSize%
  4528. HeapEnd%=SlotSize%+&8000
  4529.  HeapEnd%<=Heap% 
  4530.  0,"Can't claim space for heap"
  4531.  "OS_Heap",0,Heap%,,HeapEnd%-Heap%
  4532. heap_get(size%)
  4533.  maxfree%,nrpages%,oldheapend%,ptr%
  4534.  "OS_Heap",1,Heap% 
  4535.  ,,maxfree%
  4536.  size%>maxfree% 
  4537.  largest free block is too small - try to enlarge wimpslot and heap
  4538. xC  nrpages%=1+(size% 
  4539.  PageSize%) : 
  4540.  required # pages of memory
  4541.  "Wimp_SlotSize",SlotSize%+nrpages%*PageSize%,-1 
  4542.  SlotSize%
  4543.   oldheapend%=HeapEnd%
  4544.   HeapEnd%=SlotSize%+&8000
  4545.  "OS_Heap",5,Heap%,,HeapEnd%-oldheapend%
  4546.  "OS_Heap",1,Heap% 
  4547.  ,,maxfree% : 
  4548.  do we have enough now?
  4549.  size%>maxfree% 
  4550. complain(
  4551. msg_lookup0("NOHP"))
  4552.   ptr%=-1
  4553.  "OS_Heap",2,Heap%,,size% 
  4554.  ,,ptr%
  4555.     =ptr%
  4556. heap_release(ptr%)
  4557.  maxfree%,nrpages%,flg%
  4558.  "OS_Heap",3,Heap%,ptr%
  4559.  "OS_Heap",1,Heap% 
  4560.  ,,maxfree%
  4561.  maxfree%>PageSize% 
  4562.  more than 1 page free - try to shrink heap (page by page)
  4563. ,  nrpages%=0 : 
  4564.  # pages of memory freed
  4565. 1    
  4566.  "XOS_Heap",5,Heap%,,-PageSize% 
  4567.  ;flg%
  4568.  (flg% 
  4569.  1)=0 
  4570.       nrpages%+=1
  4571.         
  4572.  (flg% 
  4573.  1)<>0
  4574.  nrpages%>0 
  4575. 4    
  4576.  successfully shrunk heap - shrink WimpSlot
  4577. F    
  4578.  "Wimp_SlotSize",SlotSize%-nrpages%*PageSize%,-1 
  4579.  SlotSize%
  4580.      HeapEnd%=SlotSize%+&8000
  4581.  "OS_Heap",5,Heap%,,(HeapEnd%-Heap%)-Heap%!12
  4582.  *** service procs; interface with SWIs, etc. ***
  4583.  --- change a variable with given difference, but keep inside bounds ---
  4584. changevar(
  4585.  var%,diff%,up%,low%,high%)
  4586.  oldval%
  4587. oldval%=var%
  4588.  up% 
  4589.   var%+=diff%
  4590.   var%-=diff%
  4591.  var%>high% 
  4592.  var%=high%
  4593.  var%<low% 
  4594.  var%=low%
  4595.  return TRUE if changed
  4596. =(oldval%<>var%) 
  4597. readvarval(var$)
  4598.  len%
  4599.  "OS_ReadVarVal",var$,ScrapBlk%,256,0 
  4600.  ,,len%
  4601. ScrapBlk%?len%=13
  4602. =$(ScrapBlk%)
  4603.  --- return name of icon to display in browser window ---
  4604. windowicon(wflags%,open%)
  4605.  sname$,tbar%,hscroll%,vscroll%
  4606.  wflags% 
  4607.  (1<<31) 
  4608. !  tbar%=(wflags% 
  4609.  (1<<26))>0
  4610. $  hscroll%=(wflags% 
  4611.  (1<<30))>0
  4612. $  vscroll%=(wflags% 
  4613.  (1<<28))>0
  4614.    tbar%=(wflags% 
  4615.  (1<<0))>0
  4616. #  hscroll%=(wflags% 
  4617.  (1<<3))>0
  4618. #  vscroll%=(wflags% 
  4619.  (1<<2))>0
  4620. sname$="Swin_"
  4621.  tbar% 
  4622.  sname$+="t"
  4623.  hscroll% 
  4624.  sname$+="h"
  4625.  vscroll% 
  4626.  sname$+="v"
  4627.  open% 
  4628.  sname$+="o"
  4629. =sname$
  4630. modevar(mode%,v%)
  4631.  val%
  4632.  "OS_ReadModeVariable",mode%,v% 
  4633.  ,,val%
  4634.     =val%
  4635. readscreenvars
  4636.  xeig%,yeig%,xpixels%,ypixels%
  4637. xeig%=
  4638. modevar(-1,4)
  4639. yeig%=
  4640. modevar(-1,5)
  4641. xpixels%=
  4642. modevar(-1,11)
  4643. ypixels%=
  4644. modevar(-1,12)
  4645. 9PixToOS_X%=1<<xeig% : 
  4646.  # OS units that 1 pixel takes
  4647. PixToOS_Y%=1<<yeig%
  4648. EScreenSize_X%=(xpixels%+1)*PixToOS_X% : 
  4649.  screen size in OS units
  4650. )ScreenSize_Y%=(ypixels%+1)*PixToOS_Y%
  4651.  grid size must be multiple of # OS units per pixel
  4652.  Grid_SizeX%<PixToOS_X% 
  4653.   Grid_SizeX%=PixToOS_X%
  4654. -  Grid_SizeX%-=(Grid_SizeX% 
  4655.  PixToOS_X%)
  4656.  Grid_SizeY%<PixToOS_Y% 
  4657.   Grid_SizeY%=PixToOS_Y%
  4658. -  Grid_SizeY%-=(Grid_SizeY% 
  4659.  PixToOS_Y%)
  4660. seticontext(28,
  4661. (Grid_SizeX%))
  4662. seticontext(29,
  4663. (Grid_SizeY%))
  4664.  Grid_PosX%<PixToOS_X% 
  4665.   Grid_PosX%=PixToOS_X%
  4666. +  Grid_PosX%-=(Grid_PosX% 
  4667.  PixToOS_X%)
  4668.  Grid_PosY%<PixToOS_Y% 
  4669.   Grid_PosY%=PixToOS_Y%
  4670. +  Grid_PosY%-=(Grid_PosY% 
  4671.  PixToOS_Y%)
  4672. seticontext(30,
  4673. (Grid_PosX%))
  4674. seticontext(31,
  4675. (Grid_PosY%))
  4676. DTemplW_MaxCol%=(ScreenSize_X%-100-IcInfo_Width%) 
  4677.  TemplW_IconX%
  4678. setcaret(window%,icon%)
  4679.  icon%>=0 
  4680.   ScrapBlk%!0=window%
  4681.   ScrapBlk%!4=icon%
  4682.  "Wimp_GetIconState",,ScrapBlk%
  4683.   l%=
  4684. ($(ScrapBlk%!28))
  4685.  "Wimp_SetCaretPosition",window%,icon%,,,-1,l%
  4686.  invisible caret
  4687.  "Wimp_SetCaretPosition",window%,-1,0,0,1<<25
  4688. setmouseshape(i%)
  4689.  n$,xoff%,yoff%
  4690.  0 : 
  4691.  default pointer shape
  4692.     n$="ptr_default"
  4693.     xoff%=0
  4694.     yoff%=0
  4695.  1 : 
  4696.  hand pointer for moving icons
  4697.     n$="ptr_hand"
  4698.     xoff%=7
  4699.     yoff%=6
  4700.  2 : 
  4701.  pointer for resizing icons, dragging top side
  4702.     n$="ptr_sizet"
  4703.     xoff%=7
  4704.     yoff%=6
  4705.  3 : 
  4706.  pointer for resizing icons, dragging right side
  4707.     n$="ptr_sizer"
  4708.     xoff%=5
  4709.     yoff%=5
  4710.  4 : 
  4711.  pointer for resizing icons, dragging bottom side
  4712.     n$="ptr_sizeb"
  4713.     xoff%=7
  4714.     yoff%=4
  4715.  5 : 
  4716.  pointer for resizing icons, dragging left side
  4717.     n$="ptr_sizel"
  4718.     xoff%=10
  4719.     yoff%=5
  4720. Mouse_Ptt%!0=&03020100
  4721.  i%=0 
  4722.  "Wimp_SpriteOp",36,,n$,&2,xoff%,yoff%,0,Mouse_Ptt%
  4723.  "OS_SpriteOp",&100+36,SysSprites%,n$,&2,xoff%,yoff%,0,Mouse_Ptt%
  4724. MouseShape%=i%
  4725.  --- re-allocate indirected icon data and increase font count ---
  4726. iconrealloc(flagptr%,data%)
  4727.  flags%,s$,s%,len%
  4728. flags%=flagptr%!0
  4729.  (flags% 
  4730.  &800100)=&100 
  4731.   s$=
  4732. str(data%!0)
  4733. *?  len%=data%!8              : 
  4734.  don't allocate actual size!
  4735.  len%>256 
  4736.  len%=256 : 
  4737.  Basic can't handle longer strings
  4738.   s%=
  4739. heap_get(len%)
  4740.  s%>0 
  4741.     $(s%)=
  4742. s$,len%-1)
  4743.     data%!0=s%
  4744. 0&    
  4745.  (flags% 
  4746.  (data%!4>0) 
  4747. 1)      
  4748.  re-allocate validation string
  4749.       s$=
  4750. str(data%!4)
  4751.       s%=
  4752. heap_get(
  4753.  s$+1)
  4754.       
  4755.  s%>0 
  4756.         $(s%)=s$
  4757.         data%!4=s%
  4758.       
  4759.         data%!4=-1
  4760.       
  4761. :        
  4762. <G    
  4763.  allocation failed - make non-indirected and store first chars
  4764. =*    flagptr%!0=flagptr%!0 
  4765.  (1<<8))
  4766.     $data%=
  4767. s$,11)
  4768.  (flags% 
  4769.  &800040)=&40 
  4770. B!  FontUsage%((flags%)>>24)+=1
  4771.  --- release indirected icon data and decrease font count ---
  4772. iconrelease(flags%,data%)
  4773.  (flags% 
  4774.  &800100)=&100 
  4775. heap_release(data%!0)
  4776.  (flags% 
  4777.  (data%!(4)<>-1) 
  4778. K#    
  4779.  release validation string
  4780. heap_release(data%!4)
  4781.  (flags% 
  4782.  &800040)=&40 
  4783. font_lose(flags%>>24)
  4784.  --- open a window ---
  4785.        pos% = 0 -> at current position
  4786.               1 -> centered to screen
  4787.               2 -> centered unless already open
  4788.               3 -> in topleft corner unless already open
  4789.               4 -> in topright corner unless already open
  4790. openwindow(handle%,pos%)
  4791.  notopen%,cx%,cy%,dx%,dy%
  4792. ScrapBlk%!0=handle%
  4793.  "Wimp_GetWindowState",,ScrapBlk%
  4794. ^)notopen%=((ScrapBlk%!32 
  4795.  (1<<16))=0)
  4796. _    dx%=0
  4797. `    dy%=0
  4798.  pos% 
  4799.  (pos%=1) 
  4800.  notopen% 
  4801. d#      
  4802.  center window to screen
  4803.       cx%=ScreenSize_X% 
  4804.       cy%=ScreenSize_Y% 
  4805. g0      dx%=cx%-(ScrapBlk%!12+ScrapBlk%!4) 
  4806. h0      dy%=cy%-(ScrapBlk%!16+ScrapBlk%!8) 
  4807. i        
  4808.  notopen% 
  4809.       dx%=-ScrapBlk%!4
  4810. m(      dy%=ScreenSize_Y%-ScrapBlk%!16
  4811. n        
  4812.  notopen% 
  4813. q(      dx%=ScreenSize_X%-ScrapBlk%!12
  4814. r(      dy%=ScreenSize_Y%-ScrapBlk%!16
  4815. s        
  4816. ScrapBlk%!4=ScrapBlk%!4+dx%
  4817. ScrapBlk%!8=ScrapBlk%!8+dy%
  4818. w!ScrapBlk%!12=ScrapBlk%!12+dx%
  4819. x!ScrapBlk%!16=ScrapBlk%!16+dy%
  4820. ScrapBlk%!28=-1
  4821.  "Wimp_OpenWindow",,ScrapBlk%
  4822.  handle%=OptionsW% 
  4823. openpane(OptPaneW%,-1,ScrapBlk%!4,ScrapBlk%!16)
  4824. closewindow(handle%)
  4825. ScrapBlk%!0=handle%
  4826.  "Wimp_CloseWindow",,ScrapBlk%
  4827.  handle% 
  4828.  TemplW%
  4829.     ScrapBlk%!0=IcInfoW%
  4830. (    
  4831.  "Wimp_CloseWindow",,ScrapBlk%
  4832.     ScrapBlk%!0=PaletteW%
  4833. (    
  4834.  "Wimp_CloseWindow",,ScrapBlk%
  4835.  NrTemplates%>0 
  4836. !      
  4837.  i%=0 
  4838.  NrTemplates%-1
  4839.         
  4840. closetemplate(i%)
  4841.       
  4842.         
  4843.  OptionsW%
  4844.     ScrapBlk%!0=OptPaneW%
  4845. (    
  4846.  "Wimp_CloseWindow",,ScrapBlk%
  4847. openpane(handle%,behind%,pxmin%,pymax%)
  4848.  dx%,dy%
  4849.  handle% 
  4850.  OptPaneW%
  4851. A    dx%=16  : 
  4852.  distance from topleft corner of parent window
  4853.     dy%=-16
  4854. ScrapBlk%!0=handle%
  4855.  "Wimp_GetWindowState",,ScrapBlk%
  4856. 6ScrapBlk%!12=pxmin%+dx%+(ScrapBlk%!12-ScrapBlk%!4)
  4857. 5ScrapBlk%!8=pymax%+dy%-(ScrapBlk%!16-ScrapBlk%!8)
  4858. ScrapBlk%!4=pxmin%+dx%
  4859. ScrapBlk%!16=pymax%+dy%
  4860. ScrapBlk%!28=behind%
  4861.  "Wimp_OpenWindow",,ScrapBlk%
  4862. opentemplate(no%)
  4863.  no%>=0 
  4864. &  ScrapBlk%!0=TemplHandle%!(4*no%)
  4865.  "Wimp_GetWindowState",,ScrapBlk%
  4866.  (ScrapBlk%!32 
  4867.  (1<<16))=0 
  4868.     ScrapBlk%!28=-1
  4869. '    
  4870.  "Wimp_OpenWindow",,ScrapBlk%
  4871. <    $(TemplNames%+28*no%+14)=
  4872. windowicon(ScrapBlk%!32,1)
  4873. '    
  4874. seticonstate0(TemplW%,no%,0,0)
  4875. 8    
  4876.  TemplatesOpen%=0 
  4877.  PollMask%=PollMask% 
  4878.     TemplatesOpen%+=1
  4879. *    
  4880. setcaret(TemplHandle%!(4*no%),-1)
  4881. closetemplate(no%)
  4882.  no%>=0 
  4883. &  ScrapBlk%!0=TemplHandle%!(4*no%)
  4884.  "Wimp_GetWindowState",,ScrapBlk%
  4885.  (ScrapBlk%!32 
  4886.  (1<<16))>0 
  4887. (    
  4888.  "Wimp_CloseWindow",,ScrapBlk%
  4889. +    
  4890.  "Wimp_GetWindowState",,ScrapBlk%
  4891. <    $(TemplNames%+28*no%+14)=
  4892. windowicon(ScrapBlk%!32,0)
  4893. '    
  4894. seticonstate0(TemplW%,no%,0,0)
  4895. ?    
  4896.  TemplHandle%!(4*no%)=IcEd_Win% 
  4897. closewindow(IcEdW%)
  4898. A    
  4899.  TemplHandle%!(4*no%)=WinEd_Win% 
  4900. closewindow(WinEdW%)
  4901.     TemplatesOpen%-=1
  4902. 4    
  4903.  TemplatesOpen%=0 
  4904.  PollMask%=PollMask% 
  4905.  --- convert string to lowercase ---
  4906. locase(s$)
  4907.  i%=1 
  4908.   a%=
  4909. s$,i%,1))
  4910.  (a%>=65)
  4911. (a%<=90) 
  4912. s$,i%,1)=
  4913. (a%+32)
  4914.  --- convert string to uppercase ---
  4915. upcase(s$)
  4916.  i%=1 
  4917.   a%=
  4918. s$,i%,1))
  4919.  (a%>=97)
  4920. (a%<=122) 
  4921. s$,i%,1)=
  4922. (a%-32)
  4923.  --- split off leaf name from a filename ---
  4924. leafname(f$)
  4925.  p%,q%
  4926.   p%=q%+1
  4927.   q%=
  4928. f$,".",p%)
  4929.  q%=0
  4930. f$,p%)
  4931.  --- split off directory name from a filename ---
  4932. dirname(f$)
  4933.  p%,q%
  4934. f$,".",p%)
  4935.  q% > 0 
  4936.  p%=q%+1
  4937.  q%=0
  4938. f$,p%-2)
  4939.  --- get the control-terminated string at the given address ---
  4940. str(s%)
  4941.  i%,n$
  4942.  (s%?i%>31) 
  4943.  (i%<255)
  4944.   n$+=
  4945. (s%?i%)
  4946.   i%+=1
  4947. fileexists(f$)
  4948.  type%
  4949. type%=0
  4950. (f$)>0 
  4951.  "OS_File",17,f$ 
  4952.  type%
  4953. =(type%=1)
  4954.  --- set icon state in a template window ---
  4955. seticonstate(window%,icon%,eor%,clr%)
  4956.  oldflags%,newflags%
  4957. ScrapBlk%!0=window%
  4958. ScrapBlk%!4=icon%
  4959.  check if font usage is changing
  4960.  "Wimp_GetIconState",,ScrapBlk%
  4961. oldflags%=ScrapBlk%!24
  4962. )newflags%=(oldflags% 
  4963.  clr%) 
  4964.  eor%
  4965.  (newflags% 
  4966.  &800040)=&40 
  4967. "  FontUsage%(newflags%>>24)+=1
  4968.  (oldflags% 
  4969.  &800040)=&40 
  4970. font_lose(oldflags%>>24)
  4971. ScrapBlk%!8=eor%
  4972. ScrapBlk%!12=clr%
  4973.  Support%=2 
  4974.  "AEH_SetIconState",,ScrapBlk%
  4975.  "Wimp_SetIconState",,ScrapBlk%
  4976.  --- set icon state in one of TemplEd's own windows ---
  4977. seticonstate0(window%,icon%,eor%,clr%)
  4978.  oldflags%,newflags%
  4979. ScrapBlk%!0=window%
  4980. ScrapBlk%!4=icon%
  4981. ScrapBlk%!8=eor%
  4982. ScrapBlk%!12=clr%
  4983.  "Wimp_SetIconState",,ScrapBlk%
  4984. selecticon(window%,icon%,f%)
  4985.  oldflag%
  4986. ScrapBlk%!0=window%
  4987. ScrapBlk%!4=icon%
  4988.  "Wimp_GetIconState",,ScrapBlk%
  4989. *%oldflag%=(ScrapBlk%!24) 
  4990.  (1<<21)
  4991.   ScrapBlk%!8=1<<21
  4992.   ScrapBlk%!8=0
  4993. ScrapBlk%!12=1<<21
  4994.  oldflag%<>ScrapBlk%!8 
  4995.  only set when changing
  4996.  Support%=2 
  4997. 4'   
  4998.  "AEH_SetIconState",,ScrapBlk%
  4999. 6(   
  5000.  "Wimp_SetIconState",,ScrapBlk%
  5001. iconselected(window%,icon%)
  5002. ScrapBlk%!0=window%
  5003. ScrapBlk%!4=icon%
  5004.  "Wimp_GetIconState",,ScrapBlk%
  5005. ?#=((ScrapBlk%!24) 
  5006.  (1<<21)) > 0
  5007. shadeicon(window%,icon%,f%)
  5008.  oldflag%
  5009. ScrapBlk%!0=window%
  5010. ScrapBlk%!4=icon%
  5011.  "Wimp_GetIconState",,ScrapBlk%
  5012. F%oldflag%=(ScrapBlk%!24) 
  5013.  (1<<22)
  5014.   ScrapBlk%!8=(1<<22)
  5015.   ScrapBlk%!8=0
  5016. ScrapBlk%!12=1<<22
  5017.  oldflag%<>ScrapBlk%!8 
  5018.  only set when changing
  5019.  Support%=2 
  5020. P'   
  5021.  "AEH_SetIconState",,ScrapBlk%
  5022. R(   
  5023.  "Wimp_SetIconState",,ScrapBlk%
  5024. iconshaded(window%,icon%)
  5025. ScrapBlk%!0=window%
  5026. ScrapBlk%!4=icon%
  5027.  "Wimp_GetIconState",,ScrapBlk%
  5028. [#=((ScrapBlk%!24) 
  5029.  (1<<22)) > 0
  5030.  --- store pointer to indirected text icon (for use in PROCseticontext) ---
  5031. linkicontext(index%,wbuf%,icon%)
  5032. _,IconText%(index%)=wbuf%!(92+icon%*32+20)
  5033. `!IconTextWhdl%(index%)=wbuf%!0
  5034. IconTextIhdl%(index%)=icon%
  5035. seticontext(index%,text$)
  5036. $(IconText%(index%))=text$
  5037. seticonstate0(IconTextWhdl%(index%),IconTextIhdl%(index%),0,0)
  5038.  --- store pointer to text of colour-select-box ---
  5039. linkcseltext(index%,wbuf%,icon%)
  5040. k,CselText%(index%)=wbuf%!(92+icon%*32+20)
  5041. l!CselTextWhdl%(index%)=wbuf%!0
  5042. CselTextIhdl%(index%)=icon%
  5043.  --- set colour number in colour-select-box ---
  5044. setcolourbox(index%,colour%)
  5045.  c$,boxcol%
  5046. (colour%)
  5047.  colour%=&FF 
  5048.  c$="--"
  5049. $(CselText%(index%))=c$
  5050. boxcol%=&07
  5051.  colour%<16 
  5052. x2  boxcol%=(colour%<<4)+InverseColour%(colour%)
  5053. boxcol%=boxcol%<<24
  5054. seticonstate0(CselTextWhdl%(index%),CselTextIhdl%(index%),boxcol%,&FF<<24)
  5055.  --- change colour number ---
  5056. changecolourbox(index%,
  5057.  colour%,diff%,up%,bigrange%)
  5058.  newcolour%
  5059.  up% 
  5060.   newcolour%=colour%+diff%
  5061.   newcolour%=colour%-diff%
  5062.  (newcolour% 
  5063.  &FF)=255 
  5064.  newcolour%=newcolour%+diff%
  5065.  bigrange% 
  5066. E  newcolour%=newcolour% 
  5067.  &FF        : 
  5068.  colours range from 0-255
  5069.  newcolour%<0 
  5070.  newcolour%=0    : 
  5071.  colours range from 0-15
  5072.  newcolour%>&F 
  5073.  newcolour%=&F
  5074.  newcolour%<>colour% 
  5075.   colour%=newcolour%
  5076. setcolourbox(index%,colour%)
  5077.  --- find number of template corresponding with a window handle ---
  5078.  returns -1 if not a user template, -2 if it's the palette window
  5079. whichtemplate(handle%)
  5080.  (TemplHandle%!(4*i%)<>handle%) 
  5081.  (i%<NrTemplates%)
  5082.   i%+=1
  5083.  i%=NrTemplates% 
  5084.  handle%=PaletteW% 
  5085.     i%=-2
  5086. ;    i%=-1 : 
  5087.  handle does not belong to template window
  5088. settitlebar(handle%,textptr%,title$)
  5089.  xmax%,ymax%
  5090. $(textptr%)=title$
  5091. ScrapBlk%!0=handle%
  5092.  "Wimp_GetWindowOutline",,ScrapBlk%
  5093. xmax%=ScrapBlk%!12
  5094. ymax%=ScrapBlk%!16
  5095.  "Wimp_GetWindowState",,ScrapBlk%
  5096.  (ScrapBlk%!32 
  5097.  (1<<16)) 
  5098.  "Wimp_ForceRedraw",-1,ScrapBlk%!4,ScrapBlk%!16,xmax%,ymax%
  5099.  --- delete all selected icons in a window ---
  5100. deleteiconsel(window%,default%)
  5101. sel_get(window%)
  5102.  NrSelected%>0 
  5103.  i%=0 
  5104.  NrSelected%-1
  5105. /    
  5106. deleteicon(window%,SelBlk%!(4*i%),1,1)
  5107.  nothing selected - delete icon no. <default%>
  5108.  default%>=0 
  5109. deleteicon(window%,default%,1,1)
  5110. NrSelected%=0
  5111. deleteicon(win%,icon%,release%,adjustvars%)
  5112. ScrapBlk%!0=win%
  5113. ScrapBlk%!4=icon%
  5114.  "Wimp_GetIconState",,ScrapBlk%
  5115.  release% 
  5116. iconrelease(ScrapBlk%!24,ScrapBlk%+28)
  5117.  "Wimp_DeleteIcon",,ScrapBlk%
  5118.  "Wimp_ForceRedraw",win%,ScrapBlk%!8-20,ScrapBlk%!12-20,ScrapBlk%!16+20,ScrapBlk%!20+20
  5119.  adjustvars% 
  5120.  (win%=IcEd_Win%) 
  5121.  (icon%=IcEd_Icon%) 
  5122.     IcEd_Icon%=-1000
  5123.  (win%=LastMenu_Win%) 
  5124.  (icon%=LastMenu_Icon%) 
  5125.     LastMenu_Icon%=-1
  5126. setchanged(
  5127. createicon(blk%)
  5128.  dxmin%,dymin%,dxmax%,dymax%,handle%
  5129.  Grid_PosLock% 
  5130. )  dxmin%=
  5131. griddiff(blk%!4,Grid_PosX%)
  5132. )  dymin%=
  5133. griddiff(blk%!8,Grid_PosY%)
  5134.   blk%!4=blk%!4-dxmin%
  5135.   blk%!8=blk%!8-dymin%
  5136.   blk%!12=blk%!12-dxmin%
  5137.   blk%!16=blk%!16-dymin%
  5138.  Grid_SizeLock% 
  5139. *  dxmin%=
  5140. griddiff(blk%!4,Grid_SizeX%)
  5141. *  dymin%=
  5142. griddiff(blk%!8,Grid_SizeY%)
  5143. +  dxmax%=
  5144. griddiff(blk%!12,Grid_SizeX%)
  5145. +  dymax%=
  5146. griddiff(blk%!16,Grid_SizeY%)
  5147. J  dxmin%=
  5148. griddiff(blk%!4,PixToOS_X%): 
  5149.  round coords to screen pixels
  5150. )  dymin%=
  5151. griddiff(blk%!8,PixToOS_Y%)
  5152. *  dxmax%=
  5153. griddiff(blk%!12,PixToOS_X%)
  5154. *  dymax%=
  5155. griddiff(blk%!16,PixToOS_Y%)
  5156. blk%!4=blk%!4-dxmin%
  5157. blk%!8=blk%!8-dymin%
  5158. blk%!12=blk%!12-dxmax%
  5159. blk%!16=blk%!16-dymax%
  5160.  blk%!4>=blk%!12 
  5161.  blk%!12=blk%!4+4
  5162.  blk%!8>=blk%!16 
  5163.  blk%!16=blk%!8+4
  5164.  "Wimp_CreateIcon",,blk% 
  5165.  handle%
  5166.  "Wimp_ForceRedraw",blk%!0,blk%!4-12,blk%!8-12,blk%!12+12,blk%!16+12
  5167.  handle%>MaxIcons% 
  5168. complain(
  5169. msg_lookup0("MICX"))
  5170. setchanged(
  5171. =handle%
  5172.  --- calculate distance from nearest gridpoint ---
  5173. griddiff(c%,gridsize%)
  5174.  diff%
  5175. diff%=c% 
  5176.  gridsize%
  5177.  c%<0 
  5178.  (-diff%)>(gridsize%>>1) 
  5179.  diff%+=gridsize%
  5180.  diff%>(gridsize%>>1) 
  5181.  diff%-=gridsize%
  5182. =diff%
  5183.  --- copy all selected icons in a window ---
  5184. copyiconsel(window%,
  5185.  icon%,dir%)
  5186.  i%,xmin%,ymin%,xmax%,ymax%,dx%,dy%,handle%
  5187. sel_get(window%)
  5188.  (NrSelected%=0) 
  5189.  (icon%>=0) 
  5190.   SelBlk%!0=icon%
  5191.   NrSelected%=1
  5192. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  5193.  dir% 
  5194.  0 : dx%=16 : dy%=-16        : 
  5195.  fixed distance (a bit lower+right)
  5196.  1 : dx%=0 : dy%=ymax%-ymin% : 
  5197.  copy up
  5198.  2 : dx%=0 : dy%=ymin%-ymax% : 
  5199.  copy down
  5200.  3 : dx%=xmin%-xmax% : dy%=0 : 
  5201.  copy left
  5202.  4 : dx%=xmax%-xmin% : dy%=0 : 
  5203.  copy right
  5204.  NrSelected%>0 
  5205.  i%=0 
  5206.  NrSelected%-1
  5207.  copy icon
  5208.     ScrapBlk%!0=window%
  5209. "    ScrapBlk%!4=SelBlk%!(4*i%)
  5210. )    
  5211.  "Wimp_GetIconState",,ScrapBlk%
  5212.     ScrapBlk%!4=window%
  5213. #    ScrapBlk%!8=ScrapBlk%!8+dx%
  5214. %    ScrapBlk%!12=ScrapBlk%!12+dy%
  5215. %    ScrapBlk%!16=ScrapBlk%!16+dx%
  5216. %    ScrapBlk%!20=ScrapBlk%!20+dy%
  5217. H    
  5218. iconrealloc(ScrapBlk%+24,ScrapBlk%+28) : 
  5219.  copy indirected data
  5220. (    handle%=
  5221. createicon(ScrapBlk%+4)
  5222. 5    
  5223.  deselect originals - copies remain selected
  5224. -    
  5225. selecticon(window%,SelBlk%!(4*i%),0)
  5226.  icon%>=0 
  5227.  icon%=handle%
  5228. sel_get(window%)
  5229.  --- replace window definition with new one ---
  5230. redefinewindow(wbuf%,setchanged%)
  5231.  oldhandle%,no%,wasopen%,hadcaret%,newhandle%
  5232. oldhandle%=wbuf%!0
  5233.  "Wimp_GetCaretPosition",,ScrapBlk%
  5234. *&hadcaret%=(ScrapBlk%!0=oldhandle%)
  5235. +"no%=
  5236. whichtemplate(oldhandle%)
  5237. ScrapBlk%!0=oldhandle%
  5238.  "Wimp_GetWindowState",,ScrapBlk%
  5239. .%wasopen%=(ScrapBlk%!32) 
  5240.  (1<<16)
  5241.  "Wimp_DeleteWindow",,wbuf%
  5242.  "Wimp_CreateWindow",,wbuf%+4 
  5243.  newhandle%
  5244. wbuf%!0=newhandle%
  5245.  no%<>-1 
  5246. 3%  TemplHandle%!(4*no%)=newhandle%
  5247.  oldhandle%=IcEd_Win% 
  5248.   IcEd_Win%=newhandle%
  5249.  IcEd_Icon%>=0 
  5250. 83    IcEd_Icon%=-1000 : 
  5251.  invalidate icon handle
  5252.  oldhandle%=WinEd_Win% 
  5253.  WinEd_Win%=newhandle%
  5254.  oldhandle%=LastMenu_Win% 
  5255.   LastMenu_Win%=newhandle%
  5256.   LastMenu_Icon%=-1
  5257.  wasopen% 
  5258.  "Wimp_OpenWindow",,wbuf%
  5259.  hadcaret% 
  5260.  "Wimp_SetCaretPosition",newhandle%,-1,0,0,1<<25
  5261. F;$(TemplNames%+28*no%+14)=
  5262. windowicon(wbuf%!32,wasopen%)
  5263. seticonstate0(TemplW%,no%,0,0)
  5264.  setchanged% 
  5265. setchanged(
  5266. =newhandle%
  5267.  --- replace icon definition with new one ---
  5268. redefineicon(window%,icon%,blk%)
  5269.  newicon%
  5270. deleteicon(window%,icon%,0,0)
  5271.  new icon data must start at blk%+8 (as returned by Wimp_GetIconState)
  5272. blk%!4=window%
  5273. Q newicon%=
  5274. createicon(blk%+4)
  5275.  (window%=IcEd_Win%) 
  5276.  (icon%=IcEd_Icon%) 
  5277.   IcEd_Icon%=newicon%
  5278.  (window%=LastMenu_Win%) 
  5279.  (icon%=LastMenu_Icon%) 
  5280.   LastMenu_Icon%=newicon%
  5281. =newicon%
  5282.  --- renumber an icon; new number is equal to NextIconNr% ---
  5283. renumbericon(
  5284.  window%,icon%)
  5285.  i%,ip1%,ip2%,temp%
  5286. WinBlk%!0=window%
  5287.  "Wimp_GetWindowInfo",,WinBlk%
  5288.  icon%>=WinBlk%!88 
  5289.  icon%=WinBlk%!88-1
  5290.  NextIconNr%>=WinBlk%!88 
  5291.  NextIconNr%=WinBlk%!88-1
  5292. ip1%=WinBlk%+92+icon%*32
  5293. b"ip2%=WinBlk%+92+NextIconNr%*32
  5294.  swap icon data blocks in window definition
  5295.  i%=0 
  5296.   temp%=ip1%!i%
  5297.   ip1%!i%=ip2%!i%
  5298.   ip2%!i%=temp%
  5299. i&window%=
  5300. redefinewindow(WinBlk%,1)
  5301.  --- renumber selected icons, ordering based on topleft coords ---
  5302. renumbericonsel(
  5303.  window%)
  5304.  i%,j%,f%,l%
  5305. sel_get(window%)
  5306. sel_sort(window%,1,1,0,0,0,1)
  5307.  "Wimp_WhichIcon",window%,SelBlk2%,(1<<21)+(1<<23),1<<21
  5308. WinBlk%!0=window%
  5309.  "Wimp_GetWindowInfo",,WinBlk%
  5310. tBf%=NextIconNr%               : 
  5311.  first number of new numbering
  5312. u0l%=NextIconNr%+NrSelected%-1 : 
  5313.  last number
  5314.  l%>=WinBlk%!88 
  5315. wK  l%=WinBlk%!88-1            : 
  5316.  make sure new numbers are within range
  5317.   f%=l%-(NrSelected%-1)
  5318.  i%=0 
  5319.  NrSelected%-1
  5320.  replace icon with i%-th icon from sorted selection
  5321. replaceicon(WinBlk%,f%+i%,window%,SelBlk%!(4*i%))
  5322. iconselected(window%,f%+i%) 
  5323. M    
  5324.  data of unselected icon overwritten - find new number for this icon
  5325. 8    
  5326.  (SelBlk2%!(4*j%)>=f%) 
  5327.  (SelBlk2%!(4*j%)<=l%)
  5328.       j%+=1
  5329.         
  5330. ;    
  5331. replaceicon(WinBlk%,SelBlk2%!(4*j%),window%,f%+i%)
  5332.     j%+=1
  5333. &window%=
  5334. redefinewindow(WinBlk%,1)
  5335. NextIconNr%=l%+1
  5336.  --- set selected icons to same size as topleft icon ---
  5337. samesizeiconsel(window%,default%,dim%)
  5338.  i%,xsize%,ysize%,handle%
  5339. sel_get(window%)
  5340.  (NrSelected%=0) 
  5341.  (default%>=0) 
  5342.   SelBlk%!0=default%
  5343.   NrSelected%=1
  5344.  NrSelected%>0 
  5345. sel_sort(window%,1,1,0,0,0,1)
  5346.   IconBlk%!0=window%
  5347.   IconBlk%!4=SelBlk%!0
  5348.  "Wimp_GetIconState",,IconBlk%
  5349. #  xsize%=IconBlk%!16-IconBlk%!8
  5350. $  ysize%=IconBlk%!20-IconBlk%!12
  5351.  i%=0 
  5352.  NrSelected%-1
  5353.     IconBlk%!0=window%
  5354. !    IconBlk%!4=SelBlk%!(4*i%)
  5355. (    
  5356.  "Wimp_GetIconState",,IconBlk%
  5357. 1    
  5358.  dim%<>2 
  5359.  IconBlk%!16=IconBlk%!8+xsize%
  5360. 2    
  5361.  dim%<>1 
  5362.  IconBlk%!20=IconBlk%!12+ysize%
  5363. >    handle%=
  5364. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5365.  --- in wbuf%, replace data for icon ic1% with data of icon ic2% ---
  5366. replaceicon(wbuf%,ic1%,window%,ic2%)
  5367.  ib%,temp1%,temp2%
  5368. ib%=wbuf%+92+32*ic1%
  5369. ?temp1%=ib%!(-8) : 
  5370.  save 2 words just before the icon block
  5371. temp2%=ib%!(-4)
  5372. ib%!(-8)=window%
  5373. ib%!(-4)=ic2%
  5374.  "Wimp_GetIconState",,ib%-8 : 
  5375.  get icon data block
  5376. +ib%!(-8)=temp1% : 
  5377.  restore the 2 words
  5378. ib%!(-4)=temp2%
  5379.  --- update contents of icon info window ---
  5380. icinf_update
  5381.  no%,t$,i$,xmin$,xmax$,ymin$,ymax$,s$,mx%,my%,m$
  5382.  showicondata%,xmin%,xmax%,ymin%,ymax%
  5383.  "Wimp_GetPointerInfo",,PtrInfo%
  5384. #no%=
  5385. whichtemplate(PtrInfo%!12)
  5386.     t$=""
  5387.     i$=""
  5388. xmin$=""
  5389. xmax$=""
  5390. ymin$=""
  5391. ymax$=""
  5392.     s$=""
  5393.     m$=""
  5394. showicondata%=
  5395.  (no%>=0) 
  5396.   t$=$(TemplNames%+28*no%)
  5397.  PtrInfo%!16>=-1 
  5398.     ScrapBlk%!0=PtrInfo%!12
  5399. +    
  5400.  "Wimp_GetWindowState",,ScrapBlk%
  5401. 1    mx%=PtrInfo%!0-(ScrapBlk%!4-ScrapBlk%!20)
  5402. 2    my%=PtrInfo%!4-(ScrapBlk%!16-ScrapBlk%!24)
  5403.     m$=
  5404. (mx%)+","+
  5405. (my%)
  5406.  Drag_Type% 
  5407.       
  5408. K        
  5409.  moving/resizing icon(s) - show current coordinates of dragbox
  5410.         i$="..."
  5411. -        xmin%=mx%-(Drag_Ptrx%-DragBlk%!8)
  5412. .        ymin%=my%-(Drag_Ptry%-DragBlk%!12)
  5413. &        xmax%=xmin%+Drag_BoxSizex%
  5414. &        ymax%=ymin%+Drag_BoxSizey%
  5415.         showicondata%=
  5416.       
  5417. D        
  5418.  resizing icon(s) - show current coordinates of dragbox
  5419.         i$="..."
  5420.         xmin%=Drag_Box0x%
  5421.         ymin%=Drag_Box0y%
  5422. &        xmax%=xmin%+Drag_BoxSizex%
  5423. &        ymax%=ymin%+Drag_BoxSizey%
  5424.         
  5425.  MouseShape% 
  5426. 2          
  5427.  2 : ymax%+=(PtrInfo%!4-Drag_Ptry%)
  5428. 2          
  5429.  3 : xmax%+=(PtrInfo%!0-Drag_Ptrx%)
  5430. 2          
  5431.  4 : ymin%+=(PtrInfo%!4-Drag_Ptry%)
  5432. 2          
  5433.  5 : xmin%+=(PtrInfo%!0-Drag_Ptrx%)
  5434.         
  5435.         showicondata%=
  5436.       
  5437. -        
  5438.  show data of icon under pointer
  5439.         
  5440.  PtrInfo%!16>=0 
  5441.           i$=
  5442. (PtrInfo%!16)
  5443. %          ScrapBlk%!0=PtrInfo%!12
  5444. %          ScrapBlk%!4=PtrInfo%!16
  5445. /          
  5446.  "Wimp_GetIconState",,ScrapBlk%
  5447.           xmin%=ScrapBlk%!8
  5448.            xmax%=ScrapBlk%!16
  5449.            ymin%=ScrapBlk%!12
  5450.            ymax%=ScrapBlk%!20
  5451.           showicondata%=
  5452.         
  5453.         
  5454.  showicondata% 
  5455.       xmin$=
  5456. (xmin%)
  5457.       xmax$=
  5458. (xmax%)
  5459.       ymin$=
  5460. (ymin%)
  5461.       ymax$=
  5462. (ymax%)
  5463. .      s$=
  5464. (xmax%-xmin%)+"x"+
  5465. (ymax%-ymin%)
  5466.         
  5467.  t$<>$(IconText%(7)) 
  5468. seticontext(7,t$)
  5469.  i$<>$(IconText%(8)) 
  5470. seticontext(8,i$)
  5471.  xmin$<>$(IconText%(9)) 
  5472. seticontext(9,xmin$)
  5473.  xmax$<>$(IconText%(26)) 
  5474. seticontext(26,xmax$)
  5475.  ymin$<>$(IconText%(10)) 
  5476. seticontext(10,ymin$)
  5477.  ymax$<>$(IconText%(27)) 
  5478. seticontext(27,ymax$)
  5479.  s$<>$(IconText%(11)) 
  5480. seticontext(11,s$)
  5481.  m$<>$(IconText%(24)) 
  5482. seticontext(24,m$)
  5483. alignicons(window%)
  5484.  move%,imask%,type%,i%,anchorx%,anchory%
  5485.  dx1%,dx2%,dy1%,dy2%,handle%
  5486. "move%=
  5487. iconselected(AlignW%,8)
  5488. imask%=(31<<16)+(1<<21)
  5489.  "Wimp_WhichIcon",AlignW%,SelBlk%,imask%,(1<<16)+(1<<21)
  5490. type%=SelBlk%!0
  5491. sel_get(window%)
  5492.  NrSelected%>1 
  5493.  type% 
  5494. .    
  5495.  2,3 : 
  5496. sel_sort(window%,0,0,1,0,1,1)
  5497. .    
  5498.  4   : 
  5499. sel_sort(window%,0,1,0,0,1,1)
  5500. .    
  5501.  5,6 : 
  5502. sel_sort(window%,1,1,0,1,0,0)
  5503. .    
  5504.  7   : 
  5505. sel_sort(window%,1,0,1,1,1,1)
  5506.   IconBlk%!0=window%
  5507.   IconBlk%!4=SelBlk%!0
  5508.  "Wimp_GetIconState",,IconBlk%
  5509.  type% 
  5510. E      anchorx%=IconBlk%!8                                : 
  5511.  left
  5512. G      anchorx%=IconBlk%!8+(IconBlk%!16-IconBlk%!8)
  5513. 2   : 
  5514.  h centre
  5515. F      anchorx%=IconBlk%!16                               : 
  5516.  right
  5517. D      anchory%=IconBlk%!20                               : 
  5518. G      anchory%=IconBlk%!12+(IconBlk%!20-IconBlk%!12)
  5519.  v centre
  5520. G      anchory%=IconBlk%!12                               : 
  5521.  bottom
  5522.  i%=1 
  5523.  NrSelected%-1
  5524.     IconBlk%!0=window%
  5525. #!    IconBlk%!4=SelBlk%!(4*i%)
  5526. $(    
  5527.  "Wimp_GetIconState",,IconBlk%
  5528.     dx1%=0
  5529.     dx2%=0
  5530.     dy1%=0
  5531.     dy2%=0
  5532.  type% 
  5533.       
  5534. +$        dx1%=anchorx%-IconBlk%!8
  5535.         
  5536.  move% 
  5537.  dx2%=dx1%
  5538.       
  5539. .A        dx1%=anchorx%-(IconBlk%!8+(IconBlk%!16-IconBlk%!8)
  5540.         
  5541.  move% 
  5542.  dx2%=dx1%
  5543.       
  5544. 1%        dx2%=anchorx%-IconBlk%!16
  5545.         
  5546.  move% 
  5547.  dx1%=dx2%
  5548.       
  5549. 4%        dy2%=anchory%-IconBlk%!20
  5550.         
  5551.  move% 
  5552.  dy1%=dy2%
  5553.       
  5554. 7C        dy1%=anchory%-(IconBlk%!12+(IconBlk%!20-IconBlk%!12)
  5555.         
  5556.  move% 
  5557.  dy2%=dy1%
  5558.       
  5559. :%        dy1%=anchory%-IconBlk%!12
  5560.         
  5561.  move% 
  5562.  dy2%=dy1%
  5563. <        
  5564. ="    IconBlk%!8=IconBlk%!8+dx1%
  5565. >$    IconBlk%!12=IconBlk%!12+dy1%
  5566. ?$    IconBlk%!16=IconBlk%!16+dx2%
  5567. @$    IconBlk%!20=IconBlk%!20+dy2%
  5568. A=    
  5569.  IconBlk%!16<=IconBlk%!8 
  5570.  IconBlk%!16=IconBlk%!8+32
  5571. B?    
  5572.  IconBlk%!20<=IconBlk%!12 
  5573.  IconBlk%!20=IconBlk%!12+32
  5574. C>    handle%=
  5575. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5576.  --- shade the appropriate icons in the Align window
  5577. align_shadeicons
  5578. iconselected(AlignW%,3) 
  5579. iconselected(AlignW%,6) 
  5580. shadeicon(AlignW%,9,1)
  5581. shadeicon(AlignW%,9,0)
  5582. shadeicon(AlignW%,3,
  5583. iconselected(AlignW%,9))
  5584. shadeicon(AlignW%,6,
  5585. iconselected(AlignW%,9))
  5586. spaceicons(window%)
  5587.  imask%,type%,i%,distance%,space%,ib%,anchor%,dx%,dy%,handle%
  5588. U'SpaceOut_Space%=
  5589. ($(IconText%(18)))
  5590. VOimask%=(31<<16)+(1<<21) : 
  5591.  check if spacing must be horizontal or vertical
  5592.  "Wimp_WhichIcon",SpaceW%,SelBlk%,imask%,(1<<16)+(1<<21)
  5593. XBtype%=SelBlk%!0 : 
  5594.  type%=2 => horizontal, type%=3 => vertical
  5595. sel_get(window%)
  5596.  NrSelected%>1 
  5597.  type%=2 
  5598. \&    
  5599. sel_sort(window%,0,0,1,0,1,0)
  5600. ^&    
  5601. sel_sort(window%,1,0,1,1,1,0)
  5602. iconselected(SpaceW%,4) 
  5603. a!    distance%=SpaceOut_Space%
  5604. c,    
  5605.  calc available space between icons
  5606.     WinBlk%!0=window%
  5607. e(    
  5608.  "Wimp_GetWindowInfo",,WinBlk%
  5609. f.    
  5610.  start with space between outer icons
  5611.  type%=2 
  5612. h>      space%=WinBlk%!(92+32*(SelBlk%!(4*(NrSelected%-1))))
  5613. i/      space%-=WinBlk%!(92+32*(SelBlk%!0)+8)
  5614. j        
  5615. k@      space%=WinBlk%!(92+32*(SelBlk%!(4*(NrSelected%-1)))+4)
  5616. l0      space%-=WinBlk%!(92+32*(SelBlk%!0)+12)
  5617. m        
  5618. n.    
  5619.  subtract sizes of intermediate icons
  5620.  NrSelected%>2 
  5621. p"      
  5622.  i%=1 
  5623.  (NrSelected%-2)
  5624. q.        ib%=WinBlk%+92+32*(SelBlk%!(4*i%))
  5625.         
  5626.  type%=2 
  5627. s#          space%-=(ib%!8-ib%!0)
  5628.         
  5629. u$          space%-=(ib%!12-ib%!4)
  5630.         
  5631.       
  5632. x        
  5633. y*    distance%=space% 
  5634.  (NrSelected%-1)
  5635. z4    NrSelected%-=1 : 
  5636.  to avoid moving last icon
  5637.   IconBlk%!0=window%
  5638.   IconBlk%!4=SelBlk%!0
  5639.  "Wimp_GetIconState",,IconBlk%
  5640.  type% 
  5641. !    
  5642.  2 : anchor%=IconBlk%!16
  5643. !    
  5644.  3 : anchor%=IconBlk%!20
  5645.  i%=1 
  5646.  NrSelected%-1
  5647.     anchor%+=distance%
  5648.     IconBlk%!0=window%
  5649. !    IconBlk%!4=SelBlk%!(4*i%)
  5650. (    
  5651.  "Wimp_GetIconState",,IconBlk%
  5652.     dx%=0
  5653.     dy%=0
  5654.  type% 
  5655. &      
  5656.  2 : dx%=anchor%-IconBlk%!8
  5657. '      
  5658.  3 : dy%=anchor%-IconBlk%!12
  5659.         
  5660. !    IconBlk%!8=IconBlk%!8+dx%
  5661. #    IconBlk%!12=IconBlk%!12+dy%
  5662. #    IconBlk%!16=IconBlk%!16+dx%
  5663. #    IconBlk%!20=IconBlk%!20+dy%
  5664.  type% 
  5665. #      
  5666.  2 : anchor%=IconBlk%!16
  5667. #      
  5668.  3 : anchor%=IconBlk%!20
  5669.         
  5670. >    handle%=
  5671. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5672. space_shadeicons
  5673.  useavail%,i%
  5674. &useavail%=
  5675. iconselected(SpaceW%,8)
  5676.  i%=5 
  5677. shadeicon(SpaceW%,i%,useavail%)
  5678. frameicons(window%)
  5679.  i%,j%,xmin%,ymin%,xmax%,ymax%,handle%,h%,w%
  5680. %Frame_IconNo%=
  5681. ($(IconText%(32)))
  5682. $Frame_Space%=
  5683. ($(IconText%(33)))
  5684. &Frame_LabelNo%=
  5685. ($(IconText%(34)))
  5686. (Frame_LeftSpace%=
  5687. ($(IconText%(35)))
  5688. iconselected(FrameW%,5) 
  5689.  Frame_IconNo%=-1
  5690. iconselected(FrameW%,15) 
  5691.  Frame_LabelNo%=-1
  5692. sel_get(window%)
  5693.  remove frame and label icon# from selection block
  5694.  i%=0 
  5695.  NrSelected%-1
  5696.   icon%=SelBlk%!(4*i%)
  5697.   SelBlk%!(4*j%)=icon%
  5698.  (icon%<>Frame_IconNo%) 
  5699.  (icon%<>Frame_LabelNo%) 
  5700.  j%+=1
  5701.  j%=0 
  5702. dialogue(10,"")
  5703. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  5704. xmin%-=Frame_Space%
  5705. ymin%-=Frame_Space%
  5706. xmax%+=Frame_Space%
  5707. ymax%+=Frame_Space%
  5708.  Frame_IconNo%=-1 
  5709.  re-open window "around" icons
  5710.   WinBlk%!0=window%
  5711.  "Wimp_GetWindowState",,WinBlk%
  5712. (  WinBlk%!8=WinBlk%!16-(ymax%-ymin%)
  5713. (  WinBlk%!12=WinBlk%!4+(xmax%-xmin%)
  5714.   WinBlk%!20=xmin%
  5715.   WinBlk%!24=ymax%
  5716.  "Wimp_OpenWindow",,WinBlk%
  5717.  redefine frame icon
  5718.   IconBlk%!0=window%
  5719.   IconBlk%!4=Frame_IconNo%
  5720.  "Wimp_GetIconState",,IconBlk%
  5721.  Frame_LabelNo%<>-1 
  5722.     ScrapBlk%!0=window%
  5723. "    ScrapBlk%!4=Frame_LabelNo%
  5724. )    
  5725.  "Wimp_GetIconState",,ScrapBlk%
  5726. %    w%=(ScrapBlk%!16-ScrapBlk%!8)
  5727. &    h%=(ScrapBlk%!20-ScrapBlk%!12)
  5728.     h%=0
  5729.   IconBlk%!8=xmin%
  5730. )  IconBlk%!12=ymin%                  
  5731. )  IconBlk%!16=xmax%                  
  5732.    IconBlk%!20=ymax%+(h% 
  5733. ;  handle%=
  5734. redefineicon(window%,Frame_IconNo%,IconBlk%)
  5735.  Frame_LabelNo%<>-1 
  5736.  redefine label icon
  5737.     IconBlk%!0=window%
  5738. !    IconBlk%!4=Frame_LabelNo%
  5739. (    
  5740.  "Wimp_GetIconState",,IconBlk%
  5741. %    
  5742. iconselected(FrameW%,20) 
  5743.       
  5744.  centered label
  5745. )      IconBlk%!8=(xmin%+xmax%-w%) 
  5746.         
  5747.       
  5748.  left-spaced label
  5749. +      IconBlk%!8=xmin%+Frame_LeftSpace%
  5750.                   
  5751.     IconBlk%!12=ymax%
  5752. !    IconBlk%!16=IconBlk%!8+w%
  5753. "    IconBlk%!20=IconBlk%!12+h%
  5754. >    handle%=
  5755. redefineicon(window%,Frame_LabelNo%,IconBlk%)
  5756. frame_fillwin
  5757. Frame_IconNo%=SelBlk%!0
  5758. seticontext(32,
  5759. (Frame_IconNo%))
  5760. Frame_LabelNo%=SelBlk%!4
  5761. seticontext(34,
  5762. (Frame_LabelNo%))
  5763. frame_shadeicons
  5764. frame_shadeicons
  5765.  f1%,f2%,f3%,i%
  5766.  f1%=
  5767. iconselected(FrameW%,5)
  5768. 'f2%=f1% 
  5769. iconselected(FrameW%,15)
  5770. 'f3%=f2% 
  5771. iconselected(FrameW%,20)
  5772.  i%=7 
  5773. shadeicon(FrameW%,i%,f1%)
  5774. shadeicon(FrameW%,15,f1%)
  5775. shadeicon(FrameW%,16,f1%)
  5776.  i%=17 
  5777. shadeicon(FrameW%,i%,f2%)
  5778.  i%=22 
  5779. shadeicon(FrameW%,i%,f3%)
  5780. tidyicons(window%,action%)
  5781.  changed%,xmin%,xmax%,ymin%,ymax%,copy%
  5782.  ib1%,ib2%,end%,nricons%,dx%,dy%,i%,handle%
  5783. WinBlk%!0=window%
  5784.  "Wimp_GetWindowInfo",,WinBlk%
  5785. changed%=0
  5786.  action%=2 
  5787.   xmin%=WinBlk%!20
  5788.   ymax%=WinBlk%!24
  5789. (  xmax%=xmin%+(WinBlk%!12-WinBlk%!4)
  5790. (  ymin%=ymax%-(WinBlk%!16-WinBlk%!8)
  5791.   xmin%=WinBlk%!44
  5792.   ymin%=WinBlk%!48
  5793.   xmax%=WinBlk%!52
  5794.   ymax%=WinBlk%!56
  5795.  WinBlk%!88>0 
  5796.   ib1%=WinBlk%+92
  5797.   ib2%=ib1%
  5798.   end%=ib1%+32*(WinBlk%!88)
  5799.   nricons%=0
  5800.  ib1%<end%
  5801.     copy%=
  5802. (    
  5803.  change icon coords if required
  5804.     dx%=0
  5805.     dy%=0
  5806.  action% 
  5807.       
  5808. #%        
  5809.  ((ib1%!16)
  5810. (1<<23))=0 
  5811. $9          
  5812.  test if icon position is within work area
  5813. %/          
  5814.  ib1%!0<xmin% 
  5815.  dx%=xmin%-ib1%!0
  5816. &/          
  5817.  ib1%!4<ymin% 
  5818.  dy%=ymin%-ib1%!4
  5819. '/          
  5820.  ib1%!8>xmax% 
  5821.  dx%=xmax%-ib1%!8
  5822. (1          
  5823.  ib1%!12>ymax% 
  5824.  dy%=ymax%-ib1%!12
  5825. )/          
  5826.  (dx%<>0)
  5827. (dy%<>0) 
  5828.  changed%+=1
  5829.         
  5830.       
  5831. ,#        
  5832.  ((ib1%!16)
  5833. (1<<23)) 
  5834. -C          ib1%!16=(ib1%!16) 
  5835. (1<<23) : 
  5836.  reset "deleted" flag
  5837. .$          
  5838.  (ib1%!16) 
  5839.  (1<<8) 
  5840. /B            
  5841.  can't retrieve indirected data - fill in default
  5842. 0*            ib1%!20=
  5843. heap_get(ib1%!28)
  5844.             $(ib1%!20)=""
  5845. 2&            
  5846.  (ib1%!16) 
  5847.  (1<<0) 
  5848.               ib1%!24=-1
  5849.             
  5850. 5$              ib1%!24=WinBlk%!68
  5851.             
  5852.           
  5853.           
  5854.  action%=4 
  5855.             dx%=-100000
  5856.             dy%=-100000
  5857.           
  5858.           changed%+=1
  5859.         
  5860.       
  5861. ?#        
  5862.  ((ib1%!16)
  5863. (1<<23)) 
  5864. @8          copy%=
  5865.  purge - do not copy data block
  5866.           changed%+=1
  5867.         
  5868. C        
  5869.  copy% 
  5870.       ib1%!0=ib1%!0+dx%
  5871.       ib1%!4=ib1%!4+dy%
  5872.       ib1%!8=ib1%!8+dx%
  5873.       ib1%!12=ib1%!12+dy%
  5874. I?      
  5875.  move icon data to new position in window data block
  5876.       
  5877.  i%=0 
  5878.         ib2%!i%=ib1%!i%
  5879.       
  5880.       ib2%+=32
  5881.       nricons%+=1
  5882. O        
  5883.     ib1%+=32
  5884.  changed%=0 
  5885. dialogue(6,"")
  5886.     WinBlk%!88=nricons%
  5887. V*    handle%=
  5888. redefinewindow(WinBlk%,1)
  5889. W     
  5890. dialogue(7,
  5891. (changed%))
  5892. =handle%
  5893. setworkarea
  5894.  xtopleft%,ytopleft%,xsize%,ysize%,xmin%,ymin%
  5895. WinBlk%!0=LastMenu_Win%
  5896.  "Wimp_GetWindowInfo",,WinBlk%
  5897. `!xtopleft%=
  5898. ($(IconText%(12)))
  5899. a!ytopleft%=
  5900. ($(IconText%(13)))
  5901. xsize%=
  5902. ($(IconText%(14)))
  5903. ysize%=
  5904. ($(IconText%(15)))
  5905. d%xmin%=
  5906. ($(IconText%(16))) 
  5907.  &FFFF
  5908. e%ymin%=
  5909. ($(IconText%(17))) 
  5910.  &FFFF
  5911.  (xsize%<32) 
  5912.  (ysize%<32) 
  5913. complain(
  5914. msg_lookup0("IWAS"))
  5915.  xmin%>xsize% 
  5916.     xmin%=xsize%
  5917. k!    
  5918. seticontext(16,
  5919. (xmin%))
  5920.  ymin%>ysize% 
  5921.     ymin%=ysize%
  5922. o!    
  5923. seticontext(17,
  5924. (ymin%))
  5925.   WinBlk%!44=xtopleft%
  5926. r!  WinBlk%!48=ytopleft%-ysize%
  5927. s!  WinBlk%!52=xtopleft%+xsize%
  5928.   WinBlk%!56=ytopleft%
  5929. u"  WinBlk%!72=(ymin%<<16)+xmin%
  5930. v.  LastMenu_Win%=
  5931. redefinewindow(WinBlk%,1)
  5932. centericonsel(window%,default%,dim%)
  5933.  xmin%,ymin%,xmax%,ymax%,xfree%,yfree%,dx%,dy%,i%,handle%
  5934. sel_get(window%)
  5935.  (NrSelected%=0) 
  5936.  (default%>=0) 
  5937.   SelBlk%!0=default%
  5938.   NrSelected%=1
  5939.  NrSelected%>0 
  5940. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  5941.   ScrapBlk%!0=window%
  5942.  "Wimp_GetWindowState",,ScrapBlk%
  5943. 5  xfree%=(ScrapBlk%!12-ScrapBlk%!4)-(xmax%-xmin%)
  5944. )  dx%=ScrapBlk%!20+(xfree% 
  5945.  2)-xmin%
  5946. 5  yfree%=(ScrapBlk%!16-ScrapBlk%!8)-(ymax%-ymin%)
  5947. )  dy%=ScrapBlk%!24-(yfree% 
  5948.  2)-ymax%
  5949.  dim%=2 
  5950.  dx%=0
  5951.  dim%=1 
  5952.  dy%=0
  5953.  i%=0 
  5954.  NrSelected%-1
  5955.     IconBlk%!0=window%
  5956. !    IconBlk%!4=SelBlk%!(4*i%)
  5957. (    
  5958.  "Wimp_GetIconState",,IconBlk%
  5959. !    IconBlk%!8=IconBlk%!8+dx%
  5960. #    IconBlk%!12=IconBlk%!12+dy%
  5961. #    IconBlk%!16=IconBlk%!16+dx%
  5962. #    IconBlk%!20=IconBlk%!20+dy%
  5963. >    handle%=
  5964. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5965.  --- support one of the Wimp extension modules ---
  5966.  type%=0 -> none
  5967.  type%=1 -> Interface
  5968.  type%=2 -> AEH module
  5969.  type%=3 -> WimpExt
  5970.  type%=4 -> Sculptrix
  5971. support(type%)
  5972.  old%,flg%,mod$,module$
  5973. old%=Support%
  5974. Support%=type%
  5975.  type% 
  5976.  1 : mod$="Interface" : module$="InterfaceManager"
  5977.  2 : mod$="AEH"       : module$="AEHmodule"
  5978.  3 : mod$="WimpExt"   : module$="WimpExtension"
  5979.  4 : mod$="Sculptrix" : module$="Sculptrix"
  5980.  type%<>0 
  5981. modulepresent(module$) 
  5982.     Support%=old%
  5983. dialogue(3,mod$)
  5984.  Support%<>old% 
  5985.  deregister previously selected module
  5986.  old% 
  5987.       
  5988.  "XAEH_Register",-1
  5989. +      
  5990.  "XWimpExt_CloseDown",ThisTask%
  5991.  register newly selected module
  5992.  type% 
  5993.       
  5994.  "XAEH_Register",1
  5995. @      
  5996.  "XWimpExt_Initialise",16,ThisTask%,1+(1<<8)+(1<<10)
  5997. redrawall
  5998. selecticon(OptPaneW%,9,Support%=1)
  5999. selecticon(OptPaneW%,10,Support%=2)
  6000. selecticon(OptPaneW%,34,Support%=3)
  6001. selecticon(OptPaneW%,36,Support%=4)
  6002.  --- check the presence of a relocatable module ---
  6003. modulepresent(rm$)
  6004.  flg%
  6005.  "XOS_Module",18,rm$ 
  6006.  ;flg%
  6007. =(flg% 
  6008.  1)=0
  6009.  --- force the redraw of all open template windows ---
  6010. redrawall
  6011.  NrTemplates%>0 
  6012.  i%=0 
  6013.  (NrTemplates%-1)
  6014. "    Blk%!0=TemplHandle%!(4*i%)
  6015. &    
  6016.  "Wimp_GetWindowState",,Blk%
  6017.  (Blk%!32 
  6018.  (1<<16)) 
  6019. @      
  6020.  "Wimp_ForceRedraw",-1,Blk%!4,Blk%!8,Blk%!12,Blk%!16
  6021.         
  6022. setmainfname(fn$)
  6023. MainFname$=fn$
  6024.  ChangesMade% 
  6025.  fn$+=" *"
  6026. settitlebar(TemplW%,TemplTbar%,fn$)
  6027.  --- set the 'changes made' status ---
  6028. setchanged(switch%)
  6029.  title$
  6030.  ChangesMade%<>switch% 
  6031.  switch% 
  6032. !    title$=$(TemplTbar%)+" *"
  6033. 1    title$=
  6034. $(TemplTbar%),
  6035. ($(TemplTbar%))-2)
  6036. settitlebar(TemplW%,TemplTbar%,title$)
  6037.   ChangesMade%=switch%
  6038.  --- build string with info to send to !Help ---
  6039. iconhelp(no%,icon%)
  6040.  help$,p%
  6041. ,help$="Template '"+$(TemplNames%+28*no%)
  6042.  icon%>=0 
  6043. &  help$+="', Icon #"+
  6044. (icon%)+"|M"
  6045. &  ScrapBlk%!0=TemplHandle%!(4*no%)
  6046.   ScrapBlk%!4=icon%
  6047.  "Wimp_GetIconState",,ScrapBlk%
  6048.   flags%=ScrapBlk%!24
  6049.  (flags% 
  6050. +    
  6051.  0 : help$+="Non-text, non-sprite"
  6052.  1 : help$+="Text"
  6053.  2 : help$+="Sprite"
  6054. $    
  6055.  3 : help$+="Text + Sprite"
  6056.   help$+=" icon, "
  6057.  (flags% 
  6058.  &100) 
  6059. =    help$+="Indirected (max. size "+
  6060. (ScrapBlk%!36)+")|M"
  6061.  (flags% 
  6062.       
  6063.  ScrapBlk%!32=-1 
  6064. )        help$+="No validation string"
  6065.       
  6066. =        help$+="Validation string: '"+$(ScrapBlk%!32)+"'"
  6067.       
  6068.         
  6069. "    help$+="Non-indirected|M "
  6070. B  help$+="|MButton type: '"+$(IcButton%+20*((flags%>>12)
  6071.  &F))
  6072. ,  help$+="', ESG: "+
  6073. ((flags%>>16)
  6074.  &1F)
  6075.  OSversion%>=300 
  6076. J    
  6077.  replace "\" with "\\", else !Help (RiscOS 3) thinks it's a token
  6078.     p%=
  6079. help$,"\")
  6080.  p%<>0
  6081. +      help$=
  6082. help$,p%)+"\"+
  6083. help$,p%+1)
  6084.       p%=
  6085. help$,"\",p%+2)
  6086.         
  6087. $  WinBlk%!0=TemplHandle%!(4*no%)
  6088.  "Wimp_GetWindowInfo",,WinBlk%
  6089. 3  help$+="', Window background|MButton type: '"
  6090. :  help$+=$(WinButton%+20*(((WinBlk%!64)>>12)
  6091.  &F))+"'"
  6092. =help$
  6093.  --- schedule the closedown of TemplEd ---
  6094. prequit
  6095. PollMask%=PollMask% 
  6096. Quit%=
  6097.  --- send help-request to StrongHelp, for help on a subject ---
  6098. askhelp(string$)
  6099. Blk%!0=256
  6100. Blk%!12=0
  6101. Blk%!16=&43B00
  6102. '&$(Blk%+20)="Help_Word "+string$+
  6103.  "Wimp_SendMessage",17,Blk%,0
  6104.  *** procs for saving templates ***
  6105. savetemplates(fname$)
  6106.  handle%,offset%,no%
  6107. fname$,".")=0) 
  6108.  (fname$<>"<Wimp$Scrap>") 
  6109. complain(
  6110. msg_lookup0("ISLF"))
  6111.  "Hourglass_On"
  6112. save_init(fname$,NrTemplates%,handle%,offset%)
  6113.  #handle% : 
  6114. error(0) : 
  6115.  no%=0 
  6116.  NrTemplates%-1
  6117. 7?    
  6118.  SavingSelection%) 
  6119. iconselected(TemplW%,no%)) 
  6120. 8-      
  6121. save_template(no%,handle%,offset%)
  6122. 9        
  6123. save_finish(handle%,offset%)
  6124.  "OS_File",18,fname$,&FEC
  6125.  "Hourglass_Off"
  6126.  fname$=MainFname$ 
  6127. setchanged(
  6128.  QuitAfterSave% 
  6129. prequit
  6130. save_init(fname$,nrtempl%,
  6131.  handle%,
  6132.  offset%)
  6133. Save_IndexOfs%=16
  6134.  i%=0 
  6135.  FileIndexSize%-1
  6136.   FileIndex%?i%=0
  6137.  set up translation table for font handles -> internal font handles
  6138.  i%=0 
  6139.   Fra%?i%=0
  6140. Save_NrFonts%=0
  6141. N2FileIndex%!0=-1          : 
  6142.  no fonts (so far)
  6143. OLoffset%=16+nrtempl%*24+4 : 
  6144.  skip first part of file (index saved later)
  6145. handle%=
  6146.  fname$
  6147. save_template(no%,handle%,
  6148.  offset%)
  6149.  nricons%,i%,dataofs%,ib%
  6150. U'FileIndex%!(Save_IndexOfs%)=offset%
  6151. V#FileIndex%!(Save_IndexOfs%+8)=1
  6152. W9$(FileIndex%+Save_IndexOfs%+12)=$(TemplNames%+28*no%)
  6153. X"WinBlk%!0=TemplHandle%!(4*no%)
  6154.  "Wimp_GetWindowInfo",,WinBlk%
  6155.  PaneFlag%?no% 
  6156. [<  WinBlk%!32=WinBlk%!32 
  6157.  (1<<5) : 
  6158.  restore 'Pane' flag
  6159. nricons%=WinBlk%!88
  6160. dataofs%=88+32*nricons%
  6161. _6WinBlk%!68=1 : 
  6162.  reset sprite pointer to Wimp area
  6163. save_translate(WinBlk%+60,WinBlk%+76,dataofs%)
  6164.  nricons%>0 
  6165.  i%=0 
  6166.  nricons%-1
  6167.     ib%=WinBlk%+92+i%*32
  6168. d/    
  6169. save_translate(ib%+16,ib%+20,dataofs%)
  6170.  Save_Unselected% 
  6171. f$      ib%!16=ib%!16 
  6172. (1<<21))
  6173. g        
  6174.  "OS_GBPB",1,handle%,WinBlk%+4,88+32*nricons%,offset% 
  6175.  ,,,,offset%
  6176.  "Wimp_GetWindowInfo",,WinBlk%
  6177. save_icon(WinBlk%!(60),WinBlk%+76,handle%,offset%)
  6178.  nricons%>0 
  6179.  i%=0 
  6180.  nricons%-1
  6181. oM    
  6182. save_icon(WinBlk%!(92+i%*32+16),WinBlk%+92+i%*32+20,handle%,offset%)
  6183. rEFileIndex%!(Save_IndexOfs%+4)=offset%-FileIndex%!(Save_IndexOfs%)
  6184. Save_IndexOfs%+=24
  6185.  --- translate data in icon block (indirected pointers + font handles) ---
  6186. save_translate(flagptr%,data%,
  6187.  dataofs%)
  6188.  flags%,sl%,fhandle%,inthandle%
  6189. flags%=flagptr%!0
  6190.  (flags% 
  6191.  (1<<23))>0 
  6192.  icon has been deleted - fill with default data
  6193.   flagptr%!0=&07800001
  6194.   $(data%)="<Deleted>"
  6195.  1. calculate file offset for indirected icon data
  6196.  (flags% 
  6197.  &100)=&100 
  6198.  (flags% 
  6199.       
  6200. L        data%!0=dataofs%   : 
  6201.  default data for non-text,non-sprite icon
  6202. E        dataofs%+=1        : 
  6203.  empty string, 1 char is terminator
  6204.         data%!4=-1
  6205.       
  6206.         sl%=
  6207. ($(data%!0))
  6208.         data%!0=dataofs%
  6209.         dataofs%+=sl%+1
  6210. D        data%!4=1          : 
  6211.  reset sprite pointer to Wimp area
  6212.       
  6213.         sl%=
  6214. ($(data%!0))
  6215.         data%!0=dataofs%
  6216.         dataofs%+=sl%+1
  6217.         
  6218.  data%!4<>-1 
  6219.           sl%=
  6220. ($(data%!4))
  6221.           data%!4=dataofs%
  6222.           dataofs%+=sl%+1
  6223.         
  6224.         
  6225.  2. translate font handle to internal handle
  6226.  flags% 
  6227.  (1<<6) 
  6228.     fhandle%=flags%>>24
  6229.      inthandle%=Fra%?fhandle%
  6230.  inthandle%=0 
  6231.       Save_NrFonts%+=1
  6232. "      inthandle%=Save_NrFonts%
  6233. "      Fra%?fhandle%=inthandle%
  6234.         
  6235. 8    flagptr%!0=(flags% 
  6236.  &FFFFFF) 
  6237.  (inthandle%<<24)
  6238.  --- save indirected icon data to file ---
  6239. save_icon(flags%,data%,handle%,
  6240.  offset%)
  6241. 8ScrapBlk%!0=13 : 
  6242.  temporary buffer for empty string
  6243.  (flags% 
  6244.  &800100)=&100 
  6245.  flags% 
  6246.     sl%=
  6247. ($(data%!0))
  6248. B    
  6249.  "OS_GBPB",1,handle%,data%!0,sl%+1,offset% 
  6250.  ,,,,offset%
  6251.  flags% 
  6252.       
  6253.  data%!4<>-1 
  6254.         sl%=
  6255. ($(data%!4))
  6256. F        
  6257.  "OS_GBPB",1,handle%,data%!4,sl%+1,offset% 
  6258.  ,,,,offset%
  6259.       
  6260.         
  6261. 7    
  6262.  non-text,non-sprite icon - write empty string
  6263. @    
  6264.  "OS_GBPB",1,handle%,ScrapBlk%,1,offset% 
  6265.  ,,,,offset%
  6266. save_finish(handle%,offset%)
  6267.  i%,j%
  6268.  save font data
  6269.  Save_NrFonts%>0 
  6270.   FileIndex%!0=offset%
  6271.  i%=1 
  6272.  Save_NrFonts%
  6273. /    
  6274.  find font that got internal handle i%
  6275.     j%=0
  6276.  Fra%?j%<>i%
  6277.       j%+=1
  6278.         
  6279. E    
  6280.  "Font_ReadDefn",j%,FontData%+8 
  6281.  ,,FontData%!0,FontData%!4
  6282. A    
  6283.  "OS_GBPB",1,handle%,FontData%,48,offset% 
  6284.  ,,,,offset%
  6285.  save header + index entries
  6286.  "OS_GBPB",1,handle%,FileIndex%,Save_IndexOfs%+4,0
  6287.  #handle%
  6288.  *** procs for loading and deleting user templates ***
  6289. templ_add(name$,wblk%,setextent%)
  6290.  no%,nameptr%,spptr%,i%
  6291.  NrTemplates%=MaxTemplates% 
  6292. complain(
  6293. msg_lookup0("MTPX"))
  6294.   no%=NrTemplates%
  6295. '  PaneFlag%?no%=(wblk%!32) 
  6296.  (1<<5)
  6297. #  wblk%!32=(wblk%!32) 
  6298. (1<<5)
  6299.  "Wimp_CreateWindow",,wblk%+4 
  6300.  TemplHandle%!(4*no%)
  6301.   NrTemplates%+=1
  6302.   ScrapBlk%!0=TemplW%
  6303. 6  ScrapBlk%!4=8+TemplW_IconX%*(no% 
  6304.  TemplW_Cols%)
  6305. C  ScrapBlk%!12=(ScrapBlk%!4)+(TemplW_IconX%-8)-16*(11-
  6306. (name$))
  6307. 8  ScrapBlk%!16=-8-TemplW_IconY%*(no% 
  6308.  TemplW_Cols%)
  6309. 2  ScrapBlk%!8=(ScrapBlk%!16)-(TemplW_IconY%-8)
  6310. $  ScrapBlk%!20=TemplW_IconFlags%
  6311. !  nameptr%=TemplNames%+28*no%
  6312.   $(nameptr%)=name$
  6313.   ScrapBlk%!24=nameptr%
  6314. "  spptr%=TemplNames%+28*no%+14
  6315. '  $(spptr%)=
  6316. windowicon(wblk%!32,0)
  6317.   ScrapBlk%!28=spptr%
  6318.   ScrapBlk%!32=16
  6319.  "Wimp_CreateIcon",,ScrapBlk%
  6320.  DuplNames% 
  6321.     i%=0
  6322. &    
  6323.  $(TemplNames%+28*i%)<>name$
  6324.       i%+=1
  6325.         
  6326. $    
  6327.  i%<no% 
  6328. templ_delete(i%)
  6329.  setextent% 
  6330. setextent
  6331. seticonstate0(TemplW%,NrTemplates%-1,0,0)
  6332. templ_deleteall
  6333.  "Hourglass_On"
  6334.  NrTemplates%>0 
  6335.  i%=NrTemplates%-1 
  6336. templ_delete(i%)
  6337. setmainfname("Templates")
  6338. setchanged(
  6339.  "Hourglass_Off"
  6340. templ_delete(no%)
  6341.  i%,j%,wasopen%,oldhandle%
  6342. #oldhandle%=TemplHandle%!(4*no%)
  6343. WinBlk%!0=oldhandle%
  6344.  "Wimp_GetWindowInfo",,WinBlk%
  6345. iconrelease(WinBlk%!60,WinBlk%+76)
  6346.  WinBlk%!88>0 
  6347.  i%=0 
  6348.  (WinBlk%!88-1)
  6349. ?    
  6350. iconrelease(WinBlk%!(92+i%*32+16),WinBlk%+92+i%*32+20)
  6351.  "Wimp_DeleteWindow",,WinBlk%
  6352.  update browser window
  6353. WinBlk%!0=TemplW%
  6354.  "Wimp_GetWindowInfo",,WinBlk%
  6355. #wasopen%=(WinBlk%!32) 
  6356.  (1<<16)
  6357.  no%<(NrTemplates%-1) 
  6358.  move data for icons after the one that is deleted
  6359.  i%=no% 
  6360.  NrTemplates%-2
  6361.     ib%=WinBlk%+92+32*i%
  6362.  j%=0 
  6363.       ib%!j%=ib%!(j%+32)
  6364. 3    TemplHandle%!(4*i%)=TemplHandle%!(4*(i%+1))
  6365. 5    $(TemplNames%+28*i%)=$(TemplNames%+28*(i%+1))
  6366. ;    $(TemplNames%+28*i%+14)=$(TemplNames%+28*(i%+1)+14)
  6367. %    PaneFlag%?i%=PaneFlag%?(i%+1)
  6368. WinBlk%!88=WinBlk%!88-1
  6369.  "Wimp_DeleteWindow",,WinBlk%
  6370.  "Wimp_CreateWindow",,WinBlk%+4 
  6371.  TemplW%
  6372. NrTemplates%-=1
  6373. setchanged(NrTemplates%>0)
  6374. redefinebrowser(
  6375.  wasopen% 
  6376.   WinBlk%!0=TemplW%
  6377.  "Wimp_GetWindowInfo",,WinBlk%
  6378.  "Wimp_OpenWindow",,WinBlk%
  6379.  oldhandle%=IcEd_Win% 
  6380. closewindow(IcEdW%)
  6381.  oldhandle%=WinEd_Win% 
  6382. closewindow(WinEdW%)
  6383.  oldhandle%=LastMenu_Win% 
  6384.  LastMenu_Win%=-1
  6385.  NrTemplates%=0 
  6386. closewindow(StatW%)
  6387.  --- adapt extent of browser window to number of templates ---
  6388. setextent
  6389.  nrrows%,xsize%,titlesize%
  6390. 1/nrrows%=1+((NrTemplates%-1) 
  6391.  TemplW_Cols%)
  6392.  nrrows%<2 
  6393.  nrrows%=2
  6394.  NrTemplates%=0 
  6395.   xsize%=8+TemplW_IconX%
  6396.  NrTemplates% < TemplW_MaxCol% 
  6397. 7+    xsize%=8+NrTemplates%*TemplW_IconX%
  6398. 9-    xsize%=8+TemplW_MaxCol%*TemplW_IconX%
  6399. <&titlesize%=128+16*
  6400. ($(TemplTbar%))
  6401.  xsize%<titlesize% 
  6402.  xsize%=titlesize%
  6403. ScrapBlk%!0=0
  6404. ?(ScrapBlk%!4=-8-TemplW_IconY%*nrrows%
  6405. ScrapBlk%!8=xsize%
  6406. ScrapBlk%!12=0
  6407.  "Wimp_SetExtent",TemplW%,ScrapBlk%
  6408.  --- move icons in browser window to adapt to new window size ---
  6409. redefinebrowser(reopen%)
  6410.  wasopen%,i%,ib%,xsize%,ysize%
  6411. WinBlk%!0=TemplW%
  6412.  "Wimp_GetWindowInfo",,WinBlk%
  6413. J(wasopen%=((WinBlk%!32) 
  6414.  (1<<16))<>0
  6415.  WinBlk%!88>0 
  6416.  i%=0 
  6417.  (WinBlk%!88-1)
  6418.     ib%=WinBlk%+92+32*i%
  6419. N@    xsize%=(TemplW_IconX%-8)-16*(11-
  6420. ($(TemplNames%+i%*28)))
  6421.     ysize%=ib%!12-ib%!4
  6422. P1    ib%!0=8+TemplW_IconX%*(i% 
  6423.  TemplW_Cols%)
  6424.     ib%!8=(ib%!0)+xsize%
  6425. R3    ib%!12=-8-TemplW_IconY%*(i% 
  6426.  TemplW_Cols%)
  6427.     ib%!4=(ib%!12)-ysize%
  6428.  "Wimp_DeleteWindow",,WinBlk%
  6429.  "Wimp_CreateWindow",,WinBlk%+4 
  6430.  TemplW%
  6431. setextent
  6432.  reopen% 
  6433.  wasopen% 
  6434.   WinBlk%!0=TemplW%
  6435.  "Wimp_GetWindowInfo",,WinBlk%
  6436.  adapt scroll offsets if visible area exceeds work area
  6437.  (WinBlk%!20+(WinBlk%!12-WinBlk%!4))>WinBlk%!52 
  6438. ^4    WinBlk%!20=WinBlk%!52-(WinBlk%!12-WinBlk%!4)
  6439.  WinBlk%!20<0 
  6440. `*      WinBlk%!12=WinBlk%!12+WinBlk%!20
  6441.       WinBlk%!20=0
  6442. b        
  6443.  (WinBlk%!24-(WinBlk%!16-WinBlk%!8))<WinBlk%!48 
  6444. e4    WinBlk%!24=WinBlk%!48+(WinBlk%!16-WinBlk%!8)
  6445.  WinBlk%!24>0 
  6446. g(      WinBlk%!8=WinBlk%!8+WinBlk%!24
  6447.       WinBlk%!20=0
  6448. i        
  6449.  "Wimp_OpenWindow",,WinBlk%
  6450. templ_loadfile(fname$,loadsprites%)
  6451.  i%,nr%,name$,handle%,ip%,indirbuf%,sname$
  6452.  "Hourglass_On"
  6453.  "Hourglass_LEDs",1
  6454.  i%=0 
  6455.  FontUsage%(i%)>0 
  6456. uK    
  6457.  font in use - make for extra call to Font_LoseFont at end of proc
  6458.     Fra%?i%=1
  6459.     Fra%?i%=0
  6460.  NrTemplates%=0 
  6461.  fname$="<Wimp$Scrap>" 
  6462. }#    
  6463. setmainfname(NewLeafName$)
  6464. setmainfname(fname$)
  6465.  loadsprites% 
  6466. leafname(fname$)="Templates") 
  6467. 3  sname$=
  6468. dirname(fname$)+".Sprites"+SprSuffix$
  6469. fileexists(sname$) 
  6470.      
  6471. loadusersprites(sname$)
  6472. *    sname$=
  6473. dirname(fname$)+".Sprites"
  6474. 2    
  6475.  (SprSuffix$<>"") 
  6476. fileexists(sname$) 
  6477. "      
  6478. loadusersprites(sname$)
  6479.         
  6480. &indirbuf%=
  6481. heap_get(MaxIndirSize%)
  6482.  indirbuf%>0 
  6483.   handle%=
  6484.  fname$
  6485.  handle%>0 
  6486. F    
  6487.  read index of template file to check for oversized templates
  6488. :    
  6489.  "OS_GBPB",3,handle%,FileIndex%,FileIndexSize%,0
  6490.  #handle%
  6491. &    
  6492.  "Wimp_OpenTemplate",,fname$
  6493.     ip%=FileIndex%+24
  6494.     nr%=0
  6495.         
  6496. $      
  6497.  ip%!0>MaxTemplateSize% 
  6498. 5        
  6499. complain(
  6500. msg_lookup1("TTLB",$(ip%+12)))
  6501.       
  6502. :        
  6503. templ_load(nr%,name$,indirbuf%,MaxIndirSize%)
  6504.         
  6505.  nr%>0 
  6506. )          
  6507. templ_add(name$,WinBlk%,0)
  6508.         
  6509.       
  6510.       ip%+=24
  6511. 1    
  6512.  (nr%<=0) 
  6513.  (NrTemplates%=MaxTemplates%)
  6514.  "Wimp_CloseTemplate"
  6515. !    
  6516.  fname$="<Wimp$Scrap>" 
  6517. H      
  6518.  "OS_File",6,fname$ : 
  6519.  delete Wimp$Scrap file after reading
  6520.         
  6521.      
  6522. heap_release(indirbuf%)
  6523. setextent
  6524.  i%=0 
  6525.  neutralise calls of Font_FindFont done by Wimp_LoadTemplate
  6526.  Fra%?i%>1
  6527.  "Font_LoseFont",i%
  6528.     Fra%?i%-=1
  6529.  "Hourglass_Off"
  6530. openwindow(TemplW%,3)
  6531.  IcInfo_Active% 
  6532. openwindow(IcInfoW%,4)
  6533. templ_load(
  6534.  nr%,
  6535.  n$,p%,psize%)
  6536.  dx%,dy%,icon%,tb%,ib%
  6537.  "Wimp_CloseTemplate" : 
  6538. error(0) : nr%=0 : 
  6539. -n$="*"+
  6540. 0) : 
  6541.  name length must be 12
  6542.  "Wimp_LoadTemplate",,WinBlk%+4,p%,p%+psize%,Fra%,n$,nr% 
  6543.  ,,,,,n$,nr%
  6544.  nr%>0 
  6545.  make sure window origin position is within current screen size
  6546.   dx%=0
  6547.   dy%=0
  6548.  WinBlk%!4<0 
  6549.  dx%=-WinBlk%!4
  6550.  WinBlk%!8<0 
  6551.  dy%=-WinBlk%!8
  6552.  WinBlk%!12>ScreenSize_X% 
  6553.  dx%=ScreenSize_X%-WinBlk%!12
  6554.  WinBlk%!16>(ScreenSize_Y%-TBarHeight%) 
  6555. 0    dy%=ScreenSize_Y%-TBarHeight%-WinBlk%!16
  6556.   WinBlk%!4=WinBlk%!4+dx%
  6557.   WinBlk%!8=WinBlk%!8+dy%
  6558.   WinBlk%!12=WinBlk%!12+dx%
  6559.   WinBlk%!16=WinBlk%!16+dy%
  6560. ?  WinBlk%!68=UserSprites% : 
  6561.  set sprite area (CBP pointer)
  6562.  re-allocate indirected data, each field in a separate heap block
  6563.  WinBlk%!32 
  6564.  (1<<31) 
  6565.      tb%=WinBlk%!32 
  6566.  (1<<26)
  6567.     tb%=WinBlk%!32 
  6568.  (1<<0)
  6569.  tb% 
  6570. F    
  6571. iconrealloc(WinBlk%+60,WinBlk%+76) : 
  6572.  realloc title bar icon
  6573. ?    
  6574. icon_setspritearea(WinBlk%!60,WinBlk%+76,UserSprites%)
  6575. .    
  6576.  no title bar: fill data with default
  6577.     WinBlk%!60=&3D
  6578. "    $(WinBlk%+76)="<Untitled>"
  6579.  (WinBlk%!88)>0 
  6580. "    
  6581.  icon%=0 
  6582.  (WinBlk%!88)-1
  6583. !      ib%=WinBlk%+92+icon%*32
  6584. %      
  6585. iconrealloc(ib%+16,ib%+20)
  6586. >      
  6587.  set sprite pointers (indirected sprite-only icons)
  6588. 9      
  6589. icon_setspritearea(ib%!16,ib%+20,UserSprites%)
  6590.  icon%
  6591.  --- sort templates on names (case-insensitive) ---
  6592. templ_sort
  6593.  i%,j%,index%,candidate%,candname$,name$
  6594. ,i%=0 : 
  6595.  first <i%> templates are sorted
  6596.  i%<(NrTemplates%-1)
  6597.  find template with lowest name
  6598.   candidate%=i%
  6599. -  candname$=
  6600. upcase($(TemplNames%+i%*28))
  6601.  j%=i%+1 
  6602.  (NrTemplates%-1)
  6603. +    name$=
  6604. upcase($(TemplNames%+j%*28))
  6605.  name$<candname$ 
  6606.       candidate%=j%
  6607.       candname$=name$
  6608.         
  6609.  swap template data
  6610.  j%=0 
  6611.  (28-4) 
  6612. @    
  6613.  TemplNames%!(i%*28+j%),TemplNames%!(candidate%*28+j%)
  6614.  TemplHandle%!(4*i%),TemplHandle%!(4*candidate%)
  6615.  PaneFlag%?i%,PaneFlag%?candidate%
  6616.   i%+=1
  6617.  *** procs for reading and sorting selections ***
  6618.  --- get list of selected icons and count them ---
  6619. sel_get(window%)
  6620.  "Wimp_WhichIcon",window%,SelBlk%,(1<<21)+(1<<23),1<<21
  6621. NrSelected%=0
  6622.  SelBlk%!(4*NrSelected%)<>-1
  6623.   NrSelected%+=1
  6624.  --- select all icons ---
  6625. sel_all(window%)
  6626.  get all icons that are not selected nor deleted
  6627.  "Wimp_WhichIcon",window%,SelBlk%,(1<<21)+(1<<23),0
  6628.  SelBlk%!i%<>-1
  6629. selecticon(window%,SelBlk%!i%,1)
  6630.   i%+=4
  6631.  --- unselect all icons (except, maybe, for one icon) ---
  6632. sel_clear(window%,except%)
  6633.  "Wimp_WhichIcon",window%,SelBlk%,1<<21,1<<21
  6634.  SelBlk%!i%<>-1
  6635.  SelBlk%!i%<>except% 
  6636. selecticon(window%,SelBlk%!i%,0)
  6637.   i%+=4
  6638. NrSelected%=0
  6639.  --- sort icon selection (assumes selection present in SelBlk%) ---
  6640. sel_sort(window%,key1%,max1%,dir1%,key2%,max2%,dir2%)
  6641.  if key=0 then sort on horizontal coordinates, else vertical
  6642.  if max=0 then sort on minimum coordinates, else maximum
  6643.  if dir=0 then sort in descending order, else ascending
  6644.  i%,j%,index1%,index2%,ib%
  6645.  value1%,value2%,candidate%,bestsofar1%,bestsofar2%,better%
  6646. '5i%=0 : 
  6647.  first <i%> icons in selection are sorted
  6648.  key1%=0 
  6649.   index1%=0
  6650.   index1%=4
  6651.  max1% 
  6652.  index1%+=8
  6653.  key2%=0 
  6654.   index2%=0
  6655.   index2%=4
  6656.  max2% 
  6657.  index2%+=8
  6658. WinBlk%!0=window%
  6659.  "Wimp_GetWindowInfo",,WinBlk%
  6660.  i%<(NrSelected%-1)
  6661.  find icon with smallest/highest value for coordinate
  6662.   candidate%=i%
  6663. 9(  ib%=WinBlk%+92+32*(SelBlk%!(4*i%))
  6664.   bestsofar1%=ib%!(index1%)
  6665.   bestsofar2%=ib%!(index2%)
  6666.  j%=i%+1 
  6667.  (NrSelected%-1)
  6668. =*    ib%=WinBlk%+92+32*(SelBlk%!(4*j%))
  6669.     value1%=ib%!(index1%)
  6670.     value2%=ib%!(index2%)
  6671.  bestsofar1%=value1% 
  6672. A#      
  6673.  look at second sort key
  6674.       
  6675.  dir2% 
  6676. C)        better%=(value2%<bestsofar2%)
  6677.       
  6678. E)        better%=(value2%>bestsofar2%)
  6679.       
  6680. G        
  6681.       
  6682.  dir1% 
  6683. IF        better%=(value1%<bestsofar1%) : 
  6684.  looking for lowest value
  6685.       
  6686. KG        better%=(value1%>bestsofar1%) : 
  6687.  looking for highest value
  6688.       
  6689. M        
  6690.  better% 
  6691.       candidate%=j%
  6692.       bestsofar1%=value1%
  6693.       bestsofar2%=value2%
  6694. R        
  6695.  swap icons in selection sequence
  6696.  SelBlk%!(4*candidate%),SelBlk%!(4*i%)
  6697.   i%+=1
  6698.  --- calculate coords of box surrounding selected icons ---
  6699. sel_box(window%,
  6700.  xmin%,
  6701.  ymin%,
  6702.  xmax%,
  6703.  ymax%)
  6704.  assume selection present in SelBlk%
  6705. ScrapBlk%!0=window%
  6706. ScrapBlk%!4=SelBlk%!0
  6707.  "Wimp_GetIconState",,ScrapBlk%
  6708. xmin%=ScrapBlk%!8
  6709. ymin%=ScrapBlk%!12
  6710. xmax%=ScrapBlk%!16
  6711. ymax%=ScrapBlk%!20
  6712.  i%=0 
  6713.  NrSelected%-1
  6714. f   ScrapBlk%!4=SelBlk%!(4*i%)
  6715.  "Wimp_GetIconState",,ScrapBlk%
  6716.  xmin%>ScrapBlk%!8 
  6717.  xmin%=ScrapBlk%!8
  6718.  ymin%>ScrapBlk%!12 
  6719.  ymin%=ScrapBlk%!12
  6720.  xmax%<ScrapBlk%!16 
  6721.  xmax%=ScrapBlk%!16
  6722.  ymax%<ScrapBlk%!20 
  6723.  ymax%=ScrapBlk%!20
  6724.  *** setup procs ***
  6725. setup_default
  6726. IcInfo_Active%=
  6727. DuplNames%=
  6728. Hatch%=
  6729. Setup_Support%=0
  6730. Grid_SizeLock%=
  6731. Grid_SizeX%=2
  6732. Grid_SizeY%=4
  6733. Grid_PosLock%=
  6734. Grid_PosX%=2
  6735. Grid_PosY%=4
  6736. Save_Unselected%=
  6737. DeleteOutside%=
  6738. TrapDclick%=
  6739. Stats_Decimal%=
  6740. IgnoreDeskFont%=
  6741. export_settype(2)
  6742. setup_load
  6743.  f%,etype%
  6744.  (ApplDir$+".Options")
  6745.  f%=0 
  6746. setup_default
  6747.  #f% : 
  6748. error(0) : 
  6749. setup_default : 
  6750. #f%,IcInfo_Active%,DuplNames%,Hatch%,Setup_Support%
  6751. #f%,Grid_SizeLock%,Grid_SizeX%,Grid_SizeY%
  6752. #f%,Grid_PosLock%,Grid_PosX%,Grid_PosY%
  6753. #f%,Save_Unselected%,DeleteOutside%,TrapDclick%,Stats_Decimal%
  6754. #f%,IgnoreDeskFont%,etype%
  6755. export_settype(etype%)
  6756. setup_save
  6757.  (ApplDir$+".Options")
  6758.  f%<>0 
  6759.  #f% : 
  6760. error(0) : 
  6761. #f%,IcInfo_Active%,DuplNames%,Hatch%,Support%
  6762. #f%,Grid_SizeLock%,Grid_SizeX%,Grid_SizeY%
  6763. #f%,Grid_PosLock%,Grid_PosX%,Grid_PosY%
  6764. #f%,Save_Unselected%,DeleteOutside%,TrapDclick%,Stats_Decimal%
  6765. #f%,IgnoreDeskFont%,ExportType%
  6766.  *** procs for statistics window ***
  6767. stat_fillwin
  6768.  wasopen%,ysize%,maxwdef%,totindsize%,i%,wdef%,indsize%,j%,ib%
  6769.  "Hourglass_On"
  6770. sel_get(StatW%)
  6771.  SelBlk%!0=2 
  6772. (  type%=2 : 
  6773.  numbers in hexadecimal
  6774.   type%=1 : 
  6775.  decimal
  6776. WinBlk%!0=StatW%
  6777.  "Wimp_GetWindowInfo",,WinBlk%
  6778. #wasopen%=(WinBlk%!32) 
  6779.  (1<<16)
  6780.  "Wimp_DeleteWindow",,WinBlk%
  6781. WinBlk%!88=15
  6782. -ysize%=204+NrTemplates%*40 : 
  6783.  set extent
  6784. *WinBlk%!8=WinBlk%!16-WinBlk%!24-ysize%
  6785. WinBlk%!48=-ysize%
  6786.  "Wimp_CreateWindow",,WinBlk%+4 
  6787.  StatW%
  6788. WinBlk%!0=StatW%
  6789. linkicontext(25,WinBlk%,5) : 
  6790.  number of templates
  6791. linkicontext(22,WinBlk%,7) : 
  6792.  largest window definition
  6793. linkicontext(23,WinBlk%,9) : 
  6794.  total size of indirected data
  6795. maxwdef%=0
  6796. totindsize%=0
  6797.  i%=0 
  6798.  NrTemplates%-1
  6799. #  WinBlk%!0=TemplHandle%!(4*i%)
  6800.  "Wimp_GetWindowInfo",,WinBlk%
  6801.   wdef%=88+32*WinBlk%!88
  6802. 9  indsize%=
  6803. stat_calcindirsize(WinBlk%!60,WinBlk%+76)
  6804.  WinBlk%!88>0 
  6805.  j%=0 
  6806.  (WinBlk%!88-1)
  6807.       ib%=WinBlk%+92+32*j%
  6808. 6      indsize%+=
  6809. stat_calcindirsize(ib%!16,ib%+20)
  6810. stat_createicon(10,$(TemplNames%+i%*28),i%)
  6811. stat_createicon(11,
  6812. stat_num2str(WinBlk%!88),i%)
  6813. stat_createicon(12,
  6814. stat_num2str(wdef%),i%)
  6815. stat_createicon(13,
  6816. stat_num2str(indsize%),i%)
  6817. stat_createicon(14,
  6818. stat_num2str(wdef%+indsize%),i%)
  6819.   wdef%+=indsize%
  6820.  maxwdef%<wdef% 
  6821.  maxwdef%=wdef%
  6822.   totindsize%+=indsize%
  6823. seticontext(25,
  6824. (NrTemplates%))
  6825. seticontext(22,
  6826. stat_num2str(maxwdef%))
  6827. seticontext(23,
  6828. stat_num2str(totindsize%))
  6829.  wasopen% 
  6830. openwindow(StatW%,0)
  6831. openwindow(StatW%,1)
  6832.  "Hourglass_Off"
  6833.  --- calculate size of indirected data needed for an icon ---
  6834. stat_calcindirsize(flags%,data%)
  6835.  size%
  6836.  (flags% 
  6837.  &800100)=&100 
  6838.   size%=data%!8
  6839.  (flags% 
  6840.  (data%!4<>-1) 
  6841. #    size%=size%+
  6842. ($(data%!4))+1
  6843.   size%=0
  6844. =size%
  6845.  --- create an icon in the stats window ---
  6846. stat_createicon(copyfrom%,s$,line%)
  6847. ScrapBlk%!0=StatW%
  6848. ScrapBlk%!4=copyfrom%
  6849.  "Wimp_GetIconState",,ScrapBlk%
  6850.  create icon that is identical, except for string, colours and Y coord
  6851. ,ScrapBlk%!12=ScrapBlk%!12-4-40*(line%+1)
  6852.  ScrapBlk%!20=ScrapBlk%!12+40
  6853. 9ScrapBlk%!24=(ScrapBlk%!24 
  6854.  &FFFFFF) 
  6855.  Stat_Colours%
  6856. HScrapBlk%!24=ScrapBlk%!24 
  6857.  &100) : 
  6858.  icon must be not-indirected
  6859. $(ScrapBlk%+28)=s$
  6860. ScrapBlk%!4=StatW%
  6861.  "Wimp_CreateIcon",,ScrapBlk%+4
  6862.  --- convert a number to a string (hex or decimal) ---
  6863. stat_num2str(num%)
  6864.  Stats_Decimal% 
  6865.   s$=
  6866. (num%)
  6867.   s$="&"+
  6868. ~(num%)
  6869.  *** procs for handling outline fonts ***
  6870. font_lose(font%)
  6871. FontUsage%(font%)-=1
  6872.  FontUsage%(font%)=0 
  6873.  "Font_LoseFont",font%
  6874. font_loseall
  6875.  i%,j%
  6876.  i%=0 
  6877.  FontUsage%(i%)<>0 
  6878.  "Font_LoseFont",i%
  6879.  --- get font name and size from a font handle ---
  6880. font_getinfo(fhandle%,
  6881.  name$,
  6882.  xsize,
  6883.  ysize)
  6884.  xsize16%,ysize16%
  6885.  "Font_ReadDefn",fhandle%,FontData% 
  6886.  ,,xsize16%,ysize16%
  6887. name$=$(FontData%)
  6888. xsize=xsize16%/16
  6889. ysize=ysize16%/16
  6890.  *** procs for calculating & setting the minimum size of an icon ***
  6891. minimizeiconsel(window%,default%,dim%)
  6892.  i%,xsize%,ysize%,handle%
  6893. sel_get(window%)
  6894.  (NrSelected%=0) 
  6895.  (default%>=0) 
  6896.   SelBlk%!0=default%
  6897.   NrSelected%=1
  6898.  NrSelected%>0 
  6899.  i%=0 
  6900.  NrSelected%-1
  6901. (:    
  6902. miniconsize(window%,SelBlk%!(4*i%),xsize%,ysize%)
  6903.     IconBlk%!0=window%
  6904. *!    IconBlk%!4=SelBlk%!(4*i%)
  6905. +(    
  6906.  "Wimp_GetIconState",,IconBlk%
  6907. ,1    
  6908.  dim%<>2 
  6909.  IconBlk%!16=IconBlk%!8+xsize%
  6910. -2    
  6911.  dim%<>1 
  6912.  IconBlk%!20=IconBlk%!12+ysize%
  6913. .>    handle%=
  6914. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  6915. miniconsize(window%,icon%,
  6916.  minx%,
  6917.  miny%)
  6918.  sparea%,flags%,data%,text%,sprite%,indir%
  6919.  sminx%,sminy%,tminx%,tminy%,p%,val$,sname$,t$
  6920.  xmin%,ymin%,xmax%,ymax%
  6921.  l$,lspace%,lines%,b$
  6922. WinBlk%!0=window%
  6923.  "Wimp_GetWindowInfo",,WinBlk%
  6924. sparea%=WinBlk%!68
  6925. ScrapBlk%!0=window%
  6926. ScrapBlk%!4=icon%
  6927.  "Wimp_GetIconState",,ScrapBlk%
  6928. flags%=ScrapBlk%!24
  6929. data%=ScrapBlk%+28
  6930. text%=(flags% 
  6931.  1)>0
  6932. sprite%=(flags% 
  6933.  2)>0
  6934. indir%=(flags% 
  6935.  &100)>0
  6936.  indir% 
  6937.  text% 
  6938.  (data%!4<>-1) 
  6939.   val$=$(data%!4)
  6940.  sprite% 
  6941.  indir% 
  6942.  text% 
  6943. I4      
  6944.  search validation string for sprite name
  6945. J-      sname$=
  6946. validationcommand(val$,"S")
  6947.       p%=
  6948. sname$,",")
  6949.       
  6950.  p%>0 
  6951. M"        sname$=
  6952. sname$,2,p%-2)
  6953.       
  6954.         sname$=
  6955. sname$,2)
  6956.       
  6957. Q        
  6958.       sname$=$(data%!0)
  6959.       sparea%=data%!4
  6960. T        
  6961.     sname$=$(data%)
  6962. (sname$)>0 
  6963. spritesize(sname$,sparea%,sminx%,sminy%)
  6964.  text% 
  6965.  indir% 
  6966.     t$=$(data%!0)
  6967.     t$=$(data%)
  6968.  flags% 
  6969.  (1<<6) 
  6970. a5    
  6971.  calc size of string printed as outline font
  6972. b&    
  6973.  "Font_SetFont",(flags%>>24)
  6974. c;    
  6975.  "Font_StringBBox",,t$ 
  6976.  ,xmin%,ymin%,xmax%,ymax%
  6977. dG    
  6978.  "Font_ConverttoOS",,xmax%-xmin%,ymax%-ymin% 
  6979.  ,tminx%,tminy%
  6980.     tminx%+=2*PixToOS_X%
  6981.     tminy%+=2*PixToOS_Y%
  6982. h.    
  6983.  (OSversion%<350) 
  6984.  IgnoreDeskFont% 
  6985. i'      
  6986.  calc text width in BBC font
  6987.       tminx%=16*
  6988. (t$)+4
  6989. k        
  6990. l3      
  6991.  calc text width in current desktop font
  6992. m(      
  6993.  "Wimp_TextOp",1,t$ 
  6994.  tminx%
  6995.       tminx%+=8
  6996. o        
  6997. p-    tminy%=32 : 
  6998.  text height fixed to 32
  6999. r%  l$=
  7000. validationcommand(val$,"L")
  7001. (l$)>0 
  7002. t5    
  7003.  multi-line text - calc Y size, X size fixed
  7004.     lspace%=
  7005. l$,2))
  7006. v     
  7007.  lspace%=0 
  7008.  lspace%=40
  7009. w6    lines%=(tminx%-1) 
  7010.  (ScrapBlk%!16-ScrapBlk%!8)
  7011. x'    tminx%=ScrapBlk%!16-ScrapBlk%!8
  7012. y!    tminy%=lspace%*(lines%+1)
  7013.  flags% 
  7014.  (1<<4) 
  7015.   minx%=sminx%+tminx%
  7016.  minx%=0 
  7017. >    minx%=ScrapBlk%!16-ScrapBlk%!8 : 
  7018.  don't change X size
  7019. $    
  7020.  text% 
  7021.  sprite% 
  7022.  minx%+=6
  7023. 5    
  7024.  sminy%>tminy% 
  7025.  miny%=sminy% 
  7026.  miny%=tminy%
  7027.  sminx%>tminx% 
  7028.  minx%=sminx% 
  7029.  minx%=tminx%
  7030.   miny%=sminy%+tminy%
  7031.  flags% 
  7032.  (1<<2) 
  7033.  add space taken by border
  7034. %  b$=
  7035. validationcommand(val$,"R")
  7036. (b$)=0 
  7037. 7    minx%+=16 : 
  7038.  no border command - "flat" border
  7039.     miny%+=16
  7040. &    
  7041.  found command for 3-D border
  7042. b$,2)) 
  7043.       
  7044.         minx%+=24
  7045.         miny%+=24
  7046.       
  7047.         minx%+=32
  7048.         miny%+=32
  7049.       
  7050.         minx%+=16
  7051.         miny%+=16
  7052.         
  7053.  minx%<16 
  7054.  minx%=16
  7055.  miny%<16 
  7056.  miny%=16
  7057.  --- return size of a sprite in OS units ---
  7058. spritesize(name$,area%,
  7059.  xsize%,
  7060.  ysize%)
  7061.  spmode%,xpixels%,ypixels%
  7062.  area%=1 
  7063.  "XWimp_SpriteOp",40,,name$ 
  7064.  ,,,xpixels%,ypixels%,,spmode%;flg%
  7065.  "XOS_SpriteOp",296,area%,name$ 
  7066.  ,,,xpixels%,ypixels%,,spmode%;flg%
  7067.  (flg% 
  7068. 9    
  7069.  sprite not found in custom area - try wimp area
  7070. J    
  7071.  "XWimp_SpriteOp",40,,name$ 
  7072.  ,,,xpixels%,ypixels%,,spmode%;flg%
  7073.  (flg% 
  7074.   xsize%=0
  7075.   ysize%=0
  7076. *  xsize%=xpixels%<<
  7077. modevar(spmode%,4)
  7078. *  ysize%=ypixels%<<
  7079. modevar(spmode%,5)
  7080.  --- search validation string for a certain command and return it ---
  7081. validationcommand(v$,cmd$)
  7082.  upc$,loc$,p%
  7083. upc$=
  7084. (cmd$) 
  7085.  &DF)
  7086. loc$=
  7087. (cmd$) 
  7088.  &20)
  7089. v$,1)<>upc$) 
  7090. v$,1)<>loc$) 
  7091. (v$)>0)
  7092.   p%=
  7093. v$,";")
  7094.  (p%>1) 
  7095. v$,p%-1,1)="\") 
  7096. v$,";",p%+1)
  7097.  p%=0 
  7098.     v$=""
  7099.     v$=
  7100. v$,p%+1)
  7101. v$,";")
  7102.  p%>0 
  7103. v$,p%-1)
  7104.  *** procs for handling messages in the Messages file ***
  7105. msg_init
  7106.  fname$,flags%,size%,buf%
  7107. fname$=ApplDir$+".Messages"
  7108.  "MessageTrans_FileInfo",,fname$ 
  7109.  flags%,,size%
  7110.  flags% 
  7111.   buf%=0
  7112.   buf%=
  7113. heap_get(size%)
  7114. $MsgDesc%=
  7115. heap_get(17+
  7116. (fname$))
  7117. $(MsgDesc%+16)=fname$
  7118.  "MessageTrans_OpenFile",MsgDesc%,MsgDesc%+16,buf%
  7119. msg_exit
  7120.  "MessageTrans_CloseFile",MsgDesc%
  7121. MsgDesc%=0
  7122. msg_lookup0(token$)
  7123.  result$
  7124.  "MessageTrans_Lookup",MsgDesc%,token$,0 
  7125.  ,,result$
  7126. =result$
  7127. msg_lookup1(token$,param$)
  7128.  result$
  7129.  "MessageTrans_Lookup",MsgDesc%,token$,ScrapBlk%,&100,param$ 
  7130.  ,,result$
  7131. =result$
  7132. msg_lookup2(token$,param1$,param2$)
  7133.  result$
  7134.  "MessageTrans_Lookup",MsgDesc%,token$,ScrapBlk%,&100,param1$,param2$ 
  7135.  ,,result$
  7136. =result$
  7137.  *** procs for loading and using user-sprites ***
  7138.  --- load a sprite file and let all templates use the sprites
  7139. loadusersprites(fname$)
  7140.  UserSprites%<>1 
  7141. heap_release(UserSprites%)
  7142. modulepresent("OLESupport") 
  7143. )    
  7144.  "OLE_DeLinkFile",1,ThisTask%,0
  7145.  fname$="" 
  7146.   UserSprites%=1
  7147. *  UserSprites%=
  7148. loadspritefile(fname$)
  7149.  NrTemplates%>0 
  7150.  no%=0 
  7151.  NrTemplates%-1
  7152. @    
  7153. window_setspritearea(TemplHandle%!(4*no%),UserSprites%)
  7154.  UserSprites%=1 
  7155.   SpriteFname$=""
  7156.   SpriteFname$=fname$
  7157. modulepresent("OLESupport") 
  7158. %    
  7159.  "OLE_SimulateSession",&FF9
  7160. ,    
  7161.  "OLE_LinkFile",fname$,ThisTask%,0
  7162. loadspritefile(fname$)
  7163.  type%,laddr%,fsize%,ftype%,area%
  7164.  "OS_File",17,fname$ 
  7165.  type%,,laddr%,,fsize%
  7166.  (laddr%>>20) 
  7167.  &FFF=&FFF 
  7168.   ftype%=(laddr%>>8) 
  7169.  &FFF
  7170.   ftype%=-1
  7171.  (type%<>1) 
  7172.  (ftype%<>&FF9) 
  7173. complain(
  7174. msg_lookup1("NOSF",fname$))
  7175.   area%=1
  7176.   fsize%+=16
  7177.   area%=
  7178. heap_get(fsize%)
  7179.  area%>0 
  7180.     area%!0=fsize%
  7181.     area%!8=16
  7182. $    
  7183.  "OS_SpriteOp",256+9,area%
  7184. ,    
  7185.  "OS_SpriteOp",256+10,area%,fname$
  7186.  H    area%=1 : 
  7187.  couldn't allocate space in heap - reset to Wimp area
  7188. =area%
  7189. window_setspritearea(handle%,area%)
  7190.  icon%,ib%
  7191. WinBlk%!0=handle%
  7192.  "Wimp_GetWindowInfo",,WinBlk%
  7193. )$WinBlk%!68=area% : 
  7194.  CBP pointer
  7195. icon_setspritearea(WinBlk%!60,WinBlk%+76,area%)
  7196.  (WinBlk%!88)>0 
  7197.  icon%=0 
  7198.  (WinBlk%!88)-1
  7199.     ib%=WinBlk%+92+icon%*32
  7200. .0    
  7201. icon_setspritearea(ib%!16,ib%+20,area%)
  7202.  icon%
  7203. 1&handle%=
  7204. redefinewindow(WinBlk%,0)
  7205. icon_setspritearea(flags%,data%,area%)
  7206.  ((flags% 
  7207.  3)=2) 
  7208.  ((flags% 
  7209.  &100)<>0) 
  7210.   data%!4=area%
  7211.  *** procs for exporting templates ***
  7212. exporttemplates(fname$)
  7213.  handle%,no%
  7214. fname$,".")=0) 
  7215.  (fname$<>"<Wimp$Scrap>") 
  7216. complain(
  7217. msg_lookup0("ISLF"))
  7218.  "Hourglass_On"
  7219.   handle%=
  7220.  fname$
  7221.  #handle% : 
  7222. error(0) : 
  7223.  no%=0 
  7224.  NrTemplates%-1
  7225. F?    
  7226.  SavingSelection%) 
  7227. iconselected(TemplW%,no%)) 
  7228.       
  7229.  #handle%,
  7230. 48,"-")
  7231. H<      
  7232.  #handle%,"Template name: "+$(TemplNames%+28*no%)
  7233.       
  7234.  #handle%,
  7235. 48,"-")
  7236. J'      
  7237. export_template(no%,handle%)
  7238.       
  7239.  #handle%,""
  7240. L        
  7241.  #handle%
  7242.  "OS_File",18,fname$,&FFF
  7243.  "Hourglass_Off"
  7244. export_template(no%,handle%)
  7245.  nricons%,i%,ib%
  7246. V"WinBlk%!0=TemplHandle%!(4*no%)
  7247.  "Wimp_GetWindowInfo",,WinBlk%
  7248.  #handle%,"Visible area   "+
  7249. box2str(WinBlk%+4,8)
  7250.  #handle%,"Work area      "+
  7251. box2str(WinBlk%+44,8)
  7252.  #handle%,"Scroll offset  "+
  7253. rjustify(WinBlk%!20,8)+
  7254. rjustify(WinBlk%!24,8)
  7255.  #handle%,"Minimum size   ";
  7256.  #handle%,
  7257. rjustify((WinBlk%!72) 
  7258.  &FFFF,8);
  7259.  #handle%,
  7260. rjustify((WinBlk%!72)>>16,8)
  7261.  #handle%,"Flags          "+
  7262. export_wflags(WinBlk%!32,no%)
  7263.  #handle%,"Button type    "+$(WinButton%+20*((WinBlk%!64)>>12))
  7264.  #handle%,"Colours:"
  7265.  #handle%,"  Title fg     "+
  7266. (WinBlk%?36)
  7267.  #handle%,"  Title bg     "+
  7268. (WinBlk%?37)
  7269.  #handle%,"  Work fg      "+
  7270. (WinBlk%?38)
  7271.  #handle%,"  Work bg      "+
  7272. (WinBlk%?39)
  7273.  #handle%,"  Scroll outer "+
  7274. (WinBlk%?40)
  7275.  #handle%,"  Scroll inner "+
  7276. (WinBlk%?41)
  7277.  #handle%,"  Input focus  "+
  7278. (WinBlk%?42)
  7279.  #handle%,"Title bar:"
  7280. export_iconcontents(WinBlk%!60,WinBlk%+76,1)
  7281. nricons%=WinBlk%!88
  7282.  #handle%,"No. of icons   "+
  7283. (nricons%)
  7284.  nricons%>0 
  7285.  #handle%,""
  7286.  i%=0 
  7287.  nricons%-1
  7288. o%    
  7289.  #handle%,"Icon #"+
  7290. (i%)+":"
  7291.     ib%=WinBlk%+92+i%*32
  7292. q3    
  7293.  #handle%,"  Position    "+
  7294. box2str(ib%,8)
  7295. r-    
  7296. export_iconcontents(ib%!16,ib%+20,0)
  7297. export_wflags(f%,no%)
  7298.  (f% 
  7299.  (1<<0)) 
  7300. f$,1,1)="t"
  7301.  (f% 
  7302.  (1<<1)) 
  7303. f$,2,1)="M"
  7304.  (f% 
  7305.  (1<<2)) 
  7306. f$,3,1)="v"
  7307.  (f% 
  7308.  (1<<3)) 
  7309. f$,4,1)="h"
  7310.  (f% 
  7311.  (1<<4)) 
  7312. f$,5,1)="A"
  7313.  (PaneFlag%?no%) 
  7314. f$,6,1)="P"
  7315.  (f% 
  7316.  (1<<6)) 
  7317. f$,7,1)="N"
  7318.  (f% 
  7319.  (1<<7)) 
  7320. f$,8,1)="b"
  7321.  (f% 
  7322.  (1<<8)) 
  7323. f$,9,1)="A"
  7324.  (f% 
  7325.  (1<<9)) 
  7326. f$,10,1)="1"
  7327.  (f% 
  7328.  (1<<10)) 
  7329. f$,11,1)="G"
  7330.  (f% 
  7331.  (1<<11)) 
  7332. f$,12,1)="B"
  7333.  (f% 
  7334.  (1<<12)) 
  7335. f$,13,1)="H"
  7336.  (f% 
  7337.  (1<<13)) 
  7338. f$,14,1)="S"
  7339.  (f% 
  7340.  (1<<14)) 
  7341. f$,15,1)="X"
  7342.  (f% 
  7343.  (1<<15)) 
  7344. f$,16,1)="Y"
  7345. f$,17,8)=
  7346. 8,"x")
  7347.  (f% 
  7348.  (1<<24)) 
  7349. f$,25,1)="B"
  7350.  (f% 
  7351.  (1<<25)) 
  7352. f$,26,1)="C"
  7353.  (f% 
  7354.  (1<<26)) 
  7355. f$,27,1)="T"
  7356.  (f% 
  7357.  (1<<27)) 
  7358. f$,28,1)="T"
  7359.  (f% 
  7360.  (1<<28)) 
  7361. f$,29,1)="V"
  7362.  (f% 
  7363.  (1<<29)) 
  7364. f$,30,1)="A"
  7365.  (f% 
  7366.  (1<<30)) 
  7367. f$,31,1)="H"
  7368.  (f% 
  7369.  (1<<31)) 
  7370. f$,32,1)="N"
  7371. export_iconcontents(flags%,data%,tbar%)
  7372.  f$,t%,s%,i%,fn$,fx%,fy%
  7373.  (flags% 
  7374.  (1<<23)) 
  7375.  #handle%,"  ** DELETED **"
  7376.   f$=
  7377.  (flags% 
  7378.  (1<<0)) 
  7379. f$,1,1)="T"
  7380.  (flags% 
  7381.  (1<<1)) 
  7382. f$,2,1)="S"
  7383.  (flags% 
  7384.  (1<<2)) 
  7385. f$,3,1)="B"
  7386.  (flags% 
  7387.  (1<<3)) 
  7388. f$,4,1)="H"
  7389.  (flags% 
  7390.  (1<<4)) 
  7391. f$,5,1)="V"
  7392.  (flags% 
  7393.  (1<<5)) 
  7394. f$,6,1)="F"
  7395.  (flags% 
  7396.  (1<<6)) 
  7397. f$,7,1)="O"
  7398.  (flags% 
  7399.  (1<<7)) 
  7400. f$,8,1)="N"
  7401.  (flags% 
  7402.  (1<<8)) 
  7403. f$,9,1)="I"
  7404.  (flags% 
  7405.  (1<<9)) 
  7406. f$,10,1)="R"
  7407.  (flags% 
  7408.  (1<<10)) 
  7409. f$,11,1)="A"
  7410.  (flags% 
  7411.  (1<<11)) 
  7412. f$,12,1)="H"
  7413. f$,13,9)=
  7414. 9,"x")
  7415.  (flags% 
  7416.  (1<<21)) 
  7417. f$,22,1)="S"
  7418.  (flags% 
  7419.  (1<<22)) 
  7420. f$,23,1)="F"
  7421.  tbar% 
  7422. f$,3,1)="x"
  7423. f$,6,1)="x"
  7424. f$,8,1)="x"
  7425. f$,11,1)="x"
  7426.  #handle%,"  Flags        "+f$
  7427.   t%=(flags% 
  7428.  1)<>0
  7429.   s%=(flags% 
  7430.  1<<1)<>0
  7431.   i%=(flags% 
  7432.  1<<8)<>0
  7433. %    
  7434.  #handle%,"  Text         ";
  7435. ,    
  7436.  #handle%,"  Sprite       ";
  7437. '      
  7438.  #handle%,"'"+$(data%!0)+"'"
  7439.        
  7440.  (data%!4 > 0) 
  7441. ;        
  7442.  #handle%,"  Validation   "+"'"+$(data%!4)+"'"
  7443.       
  7444. 1      
  7445.  #handle%,"  Max. length  "+
  7446. (data%!8)
  7447.         
  7448. #      
  7449.  #handle%,"'"+$data%+"'"
  7450.         
  7451.  tbar%=0 
  7452. H    
  7453.  #handle%,"  Button type  "+$(IcButton%+20*((flags%>>12) 
  7454.  15))
  7455. 9    
  7456.  #handle%,"  ESG          "+
  7457. ((flags%>>16) 
  7458.  (flags% 
  7459.  (1<<6)) 
  7460. 5    
  7461. font_getinfo((flags%>>24) 
  7462.  255,fn$,fx%,fy%)
  7463. .    
  7464.  #handle%,"  Font         "+fn$+", ";
  7465. *    
  7466.  #handle%,
  7467. (fx%)+"x"+
  7468. (fy%)+" pt"
  7469.  tbar%=0 
  7470. ;      
  7471.  #handle%,"  Fg colour    "+
  7472. ((flags%>>24) 
  7473. ;      
  7474.  #handle%,"  Bg colour    "+
  7475. ((flags%>>28) 
  7476.         
  7477. box2str(p%,width%)
  7478. rjustify(p%!0,width%)
  7479. rjustify(p%!4,width%)
  7480. rjustify(p%!8,width%)
  7481. rjustify(p%!12,width%)
  7482. 2s$+="    ("+
  7483. (p%!8-p%!0)+"x"+
  7484. (p%!12-p%!4)+")"
  7485. rjustify(x%,width%)
  7486. (s$)<width% 
  7487. width%-
  7488. (s$)," ")+s$
  7489.  *** procs for exporting icon names ***
  7490. export_settype(type%)
  7491. ExportType%=type%
  7492.  type% 
  7493.  0 : $(ExportFileIcon%)="file_ffb"
  7494.  1,2 : $(ExportFileIcon%)="file_fff"
  7495. seticonstate0(ExportW%,2,0,0)
  7496. selecticon(ExportW%,3+type%,1)
  7497. export_savenames(fname$)
  7498.  handle%,no%,line%
  7499. fname$,".")=0) 
  7500.  (fname$<>"<Wimp$Scrap>") 
  7501. complain(
  7502. msg_lookup0("ISLF"))
  7503.  "Hourglass_On"
  7504.   line%=1
  7505.   handle%=
  7506.  fname$
  7507.  #handle% : 
  7508. error(0) : 
  7509.  ExportType% 
  7510. J      
  7511. export_basicline(handle%,
  7512. (&DD)+" "+
  7513. (&F2)+"iconnumbers",line%)
  7514. )      
  7515.  #handle%,"/* icon numbers */"
  7516. &      
  7517.  #handle%,"# icon numbers" 
  7518.   line%+=1
  7519.  no%=0 
  7520.  NrTemplates%-1
  7521. -    
  7522. export_savenames0(handle%,no%,line%)
  7523.  ExportType% 
  7524. 1      
  7525. export_basicline(handle%,
  7526. (&E1),line%)
  7527.       
  7528.  #handle%,13
  7529.       
  7530.  #handle%,&FF
  7531. %      
  7532.  "OS_File",18,fname$,&FFB
  7533. %      
  7534.  "OS_File",18,fname$,&FFF
  7535.  #handle%
  7536.  "Hourglass_Off"
  7537. export_savenames0(handle%,no%,
  7538.  line%)
  7539.  tname$,nricons%,i%,n$
  7540.  tname$=$(TemplNames%+28*no%)
  7541. "WinBlk%!0=TemplHandle%!(4*no%)
  7542.  "Wimp_GetWindowInfo",,WinBlk%
  7543. nricons%=WinBlk%!88
  7544.  nricons%>0 
  7545.  i%=0 
  7546.  nricons%-1
  7547.     ib%=WinBlk%+92+i%*32
  7548. 1    
  7549.  ((ib%!16 
  7550.  &101)=&101) 
  7551.  (ib%!24<>-1) 
  7552. 2      n$=
  7553. validationcommand($(ib%!24),"N"),2)
  7554.       
  7555. (n$)>0 
  7556.         
  7557.  ExportType% 
  7558.           
  7559. "R            
  7560. export_basicline(handle%,
  7561. locase(tname$+"_"+n$)+"%="+
  7562. (i%),line%)
  7563.           
  7564. $>            n$="#define "+
  7565. upcase(tname$+"_"+n$)+" "+
  7566.             
  7567.  #handle%,n$
  7568.           
  7569. '3            n$=
  7570. upcase(tname$+"_"+n$)+":"+
  7571.             
  7572.  #handle%,n$ 
  7573.         
  7574.         line%+=1
  7575.       
  7576. ,        
  7577. export_basicline(handle%,l$,lineno%)
  7578.  #handle%,13
  7579.  #handle%,lineno%>>8
  7580.  #handle%,lineno%
  7581.  #handle%,
  7582. (l$)+4
  7583.  #handle%,l$;
  7584.